选项/资源
(1) filters
js部分
var vm = new Vue({
el:'#app',
data: {},
mounted: function() {},
filters:{
formatMoney: function (value,type) {
return "¥ "+value.toFixed(2) + type; //value是默认参数
},
},
methods:{}
})
----------------------------
html部分
{{product.productPrice*product.productQuentity | formatMoney('元')}} //第二个参数
---------------------------
输出结果: ¥ xxxx.00 元
全局API
(1)Vue.filter
Vue.filter( id, [definition] )
--------------------------------------
参数:
- {string} id
- {Function} [definition]
--------------------------------------
用法:
// 注册
Vue.filter('my-filter', function (value) {
// 返回处理后的值
})
// getter,返回已注册的过滤器
var myFilter = Vue.filter('my-filter')
-------------------------------------------
例子:
Vue.filter('formatMoney', function(value,type) {
return "¥ "+value.toFixed(2) + type;
} )
指令
(1) v-modal
限制: