<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="http://unpkg.com/vue@next"></script>
</head>
<body>
<div id="root"></div>
</body>
<script>
let app = Vue.createApp({
//之前计算属性写法
// computed: {
// aa() {
// return this.a + this.b
// },
// },
setup() {
const {
ref,
computed
} = Vue
const count = ref(0)
const handleChange = () => {
count.value += 1
}
// count2 = computed(() => {
// return count.value += 2
// })
const add = computed({
get: () => {
return count.value += 2
},
set: () => {
return count.value = 5
}
})
setTimeout(() => {
add.value = 50
}, 1000)
return {
count,
handleChange,
add
}
},
template: '<div @click=handleChange>{{count}}----------{{add}}</div>',
methods: {
}
})
app.mount('#root')
</script>
</html>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)