鍍金池/ 問答/網(wǎng)絡(luò)安全  HTML/ vue2.0 在input 中使用filter 局部過濾器

vue2.0 在input 中使用filter 局部過濾器

小弟最近在學(xué)習(xí)vue2.0的局部過濾器,但是在input中使用filter 一直報(bào)錯(cuò),兄弟們,幫忙看看吧

<template>

<div>
    <input type="text"
           v-model="message | change">
</div>

</template>

<script>

 export default {
     data(){
         return {
             message:""
         }
     },
     filters:{
         change:function(value){
               return value + "4";
         }
     }
 }

</script>

圖片描述

回答
編輯回答
兔囡囡

change 名字換另外一個(gè)名字,試一下

2018年7月21日 08:40
編輯回答
老梗

可以使用計(jì)算屬性轉(zhuǎn)換一下,在計(jì)算屬性中對v-model的值進(jìn)行計(jì)算,然后返回,demo看這里https://github.com/vippiv/vue...
這是在線鏈接,過濾后只顯示前5個(gè)字符
http://www.ftc20.com/demo/vue...

2017年5月22日 10:38
編輯回答
挽青絲

好像是filter,不是filters,filter 不能和v-model一起用,只能和v-bind 或者 {{}}中使用

https://cn.vuejs.org/v2/guide...

2018年1月13日 20:45
編輯回答
孤慣

想問問樓主,這個(gè)問題你是怎么處理的呢,現(xiàn)在我也是碰到這個(gè)一模一樣的問題了,再v-module中不能使用過濾器,有什么更好的方式來實(shí)現(xiàn)這過濾器嗎?

2018年9月16日 16:53
編輯回答
互擼娃

用computed吧,vue2里面v-model不能用過濾器了

2017年12月17日 10:04