环境安装配置这几个视频
setup函数定义常量,数组,方法。需要return出去。
<template>
<div>{{res}}</div>
<div v-for="(item,index) in arr":key="index">
<h1>{{item}}
</h1>
</div>
<button @click="btn">按钮</button>
</template>
<script>
export default {
setup(){
const res='123'
const arr=['1','2','3']
function btn( ) {
console.log('按钮事件')
}
return{res,arr,btn}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>