Vue过滤器
<template>
<div>
全局指令:<input type="text" name="" id="" value="" v-focus/> 局部指令:
<input type="text" name="" id="" value="" v-focus1/>
<p v-fontCss>自定义指令字体颜色</p>
<p>{{ price | moneyUity }}</p>
</div>
</template>
<script>
export default {
name: 'input1',
data() {
return {
msg: '子组件数据',
price: 100
}
},
directives: {
focus1: {
inserted: e1 => {
e1.focus()
}
},
fontCss: e1 => {
e1.style.color = 'red'
}
},
filters: {
moneyUity(obj) {
if(!isNaN(obj)) {
return '¥' + obj
}
return obj
}
}
}
</script>
<style>
</style>