本文主要是介绍P9 计算属性 computed,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head><meta charset="UTF-8"><title>Title</title>
</head>
<body>
<!--view层 模板-->
<div id="app">currentTime1()方法: {{currentTime1()}}<br>currentTime2属性: {{currentTime2}}
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>var vm = new Vue({el:"#app",data:{message:"hello,vue!"},methods:{currentTime1: function () {return Date.now();}},computed: {currentTime2: function () {this.message;return Date.now();}}});
</script></body>
</html>
这篇关于P9 计算属性 computed的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!