原创 首页 技术

setup 语法糖

LinJHS 50

前言

平时没怎么见过的写法:

<script setup>

</script>

但用起来相当爽,减少了很多代码量。

Ref

<script setup>
import { ref } from 'vue';

const testData = ref('')
// 使用方法
testData.value = 'Hello'
</script>  

<template>
<div>{{testData}}</div>
</template>

Props

const props = defineProps({
  myData: String
});
// 使用方法
const test = props.myData

至于其他的暂时用不到,没有去了解。

分享
如果这篇文章帮到你,可以请我喝一杯茶。

微信扫码打开

请我喝杯茶

如果这篇文章帮到你,可以请我喝一杯茶。

微信收款码
在商城请我一杯