我使用Vue 3.1.1
我在实验阶段使用脚本设置和单个文件组件。使用脚本设置,我了解defineProps、defineEmit和useContext,但我不了解如何使用渲染函数。
<script lang="ts" setup>
import { defineProps } from 'vue'
const props = defineProps<{
text: string
}>()
const handleClick = () => {
console.log('click!!')
}
// Render function...
/* The template I want to create.
<button
class="btn btn-primary"
type="button"
@click="handleClick"
>
{{ props.text }}
</button>
*/
</script>
Run Code Online (Sandbox Code Playgroud) javascript vue.js vuejs3 vue-composition-api vue-script-setup