vue再读45-计算属性 基本使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
</style>
<body>
<!-- 全局自定义指令 -->
<div id="abc">
{{msg}}
<p>
{{str}}
</p>
</div>
<script src="./js/vue.js"></script>
<script>
/* Vue.directive('focus', {
inserted(el) {
//该自定义指令的调用者
el.focus();
}
}) */
var vm = new Vue({
el: '#abc',
//模板ajax返回的数据
data: {
//数据依赖另外一个数据
msg: 'abc',
},
//局部自定义指令
//通过computed计算
computed: {
str: function() {
return this.msg + 'xyz'
}
},
methods: {
},
})
</script>
<!-- 列表渲染 -->
<!-- 1渲染数组 -->
<!-- 2c处理无数据的时候 -->
</body>
</html>


浙公网安备 33010602011771号