case01
过滤器(局部filters:过滤金额)
html:
<li class="product" v-for="(item, index) in phoneList" :key="index">
<a :href="'/#/product/'+item.id" target="_blank">
<div class="pro-price">{
{item.price | currency}}</div>
</a>
</li>
js:
filters: {
currency (val) {
if (!val) return '0.00' // 一项item.price为空,则返回0.00
return '¥' + val.toFixed(2) + '元' //保留两位小数
}
}
case02
子传父通信
- 见下面这个例子
子组件
<template>
<div v-show="showModal">
<slot name="body"></slot>
<a @click="$emit('cancel')" href="javas