admin-vue/05-v-on属性的使用/复习/复习computed中getter与setter属性....

36 lines
719 B
HTML

<!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>
</head>
<body>
<div id="app">
{{fulltext}}
</div>
</body>
<script src="../00-tools/JavaScript/vue.js"></script>
<script>
const vue=new Vue({
el:"#app",
data:{
full:"你好",
text:"世界",
},
computed:{
fulltext:{
set:function(val){
const word=val.split(" ")
this.full=word[0]
this.text=word[1]
},
get:function(){
return this.full+" "+this.text
}
}
}
})
</script>
</html>