其他分享
首页 > 其他分享> > VUE框架计算属性初始

VUE框架计算属性初始

作者:互联网

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue3.js"></script>

</head>
<body>

<div id="app">

<table border="1">
<tr>
<td>序号</td>
<td>书籍名称</td>
<td>书籍价格</td>
</tr>

<tr v-for="(book,index) in filterBook2">
<template v-if="book.price>200">
<td>{{index}}</td>
<td>{{book.title}}</td>
<td>{{book.price}}</td>
</template>

</tr>

</table>
<p>方法: {{yyy()}}</p>
<p>计算属性: {{xxx}}</p>
<p>filterBook2: {{filterBook2}}</p>

</div>

<script>

// 数据驱动界面
var vm = Vue.createApp({
data(){
return {
books: ["西游记","水浒传","三国演义","红楼梦"],
books2: [
{title: "西游记", price: 199},
{title: "水浒传", price: 299},
{title: "三国演义", price: 399},
{title: "红楼梦", price: 499}
]
}
},
methods: {
yyy(){
return 200
}
},
computed: {
xxx(){
return 100
},
filterBook2(){
return this.books2.filter(function (item) {
if(item.price>200){
return item
}
})
}
},
}).mount("#app")

</script>

</body>
</html>

 

标签:200,VUE,return,title,price,item,filterBook2,初始,属性
来源: https://www.cnblogs.com/A121/p/16368775.html