tips:
example:
<!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="https://unpkg.com/vue@3"></script>
</head>
<body>
<div id="leo">
{{string}}
{{sky}}
<input type="button" value="go" @click="change"/>
</div>
<script>
var vm = Vue.createApp({
data(){
return {
"string":"helloVue3"
}
},
computed: {
"sky": {
get() {
//console.log(456)
return '10'
},
set(value) {
this.string=value
// console.log(123)
}
}
},
"methods":{
change(){
//this.sky='hello Vue.js'
this.sky='abc'
}
}
}).mount("#leo");
setTimeout(function(){
vm.sky='good job.'
}, 2000)
</script>
</body>
</html>
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。