vue的计算属性的set方法--几乎不用,了解就行
2017-11-21 13:09
1016 查看
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="vue.js"></script> </head> <style type="text/css"> #app { margin: 50px auto; width: 500px; } fieldset{ border: 1px solid orange; } fieldset input{ width: 400px; height: 30px; margin: 10px 0; } table{ width: 500px; border: 1px solid orange; text-align: center; margin-top: 40px; } thead{ background-color: orange; color: white; } button{ width: 90px; height: 40px; background-color: rosybrown; } </style> <body> <div id="app"> <p>{{fullName }}</p> <button @click="deal()">调用计算属性的setter方法</button> </div> <script type="text/javascript"> new Vue({ el: '#app', data: { fistName:'zhang', lastName:'sanfeng' }, methods:{ deal(){ this.fullName='Token Lily' } } , computed:{ // fullName(){ // return this.fistName+this.lastName // } fullName:{ fullName(){ return this.fistName+this.lastName }, //set方法 set(str){ let nameArr=str.split(''); this.firstName=nameArr[0]; this.lastName=nameArr[1]; alert(str) } } //get方法 } }) </script> </body> </html>
相关文章推荐
- 关闭Vue计算属性自带的缓存功能方法
- vue.js使用之计算属性与方法返回的差别
- vue中的计算属性的使用和vue实例的方法示例
- vue 计算属性 get 和set
- Vue.js中计算属性和方法的区别
- vue 计算属性computed和观察watch 和方法methods
- 详解vue 计算属性与方法跟侦听器区别(面试考点)
- vue 更改计算属性后select选中值不更改的解决方法
- Swift2.x 中类的计算属性set方法不能访问自身值
- vue计算属性的使用和vue实例的方法
- 关于vue的使用计算属性VS使用计算方法的问题
- Vue1.0学习总结(3)———vue1.0的生命周期、vue计算属性computed的使用、vue实例(vm)上方法总结、vue结合动画使用
- vue.js计算属性setter
- Spring中使用Map、Set、List、数组、属性集合的注入方法配置文件
- Vue计算属性的使用
- Vue.js 学习4 计算属性
- 使用weight属性时View宽度的计算方法
- Vue中计算属性与class,style绑定
- java类中为什么设置set和get方法操作属性
- vue计算属性