※前提条件:vue3 的uniapp开发
根节点为 <template>,这个 <template> 下在App、H5可以有多个根 <view> 组件,在小程序只能有一个根 <view> 组件。
一个组件的 data 选项必须是一个函数。
#codeprettify{{
<template>
<view>
<text>{{userName}}</text>
</view>
/template>
script>
export default { data() { return { "userName":"foo" } } }/script> }}
Comment: