Vue js apply filter on v-model in an input field

前端 未结 7 1685
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-03 22:37

Hope someone can help me! I have made a directive wrapping the Jasny Bootstrap Plugin more specifically the input-mask thing and everything goes well!

Now I have made a

7条回答
  •  独厮守ぢ
    2021-02-03 23:08

    I've found that I can filter input using the ordinary component v-bind:value / v-on:input dance without resorting to data or watch clauses if I just call $forceUpdate() after emitting the filtered value:

    The Vue component:

    {
      props: ['value'],
      methods: {
        mEmit: function(EVT) {
          const VAL      = EVT.target.value;
          var   FILTERED = myFilterFunction(VAL);
          this.$emit('input', FILTERED);
          this.$forceUpdate();
        }
      }
    }
    

    The component HTML (data is filtered as it is entered):

      
    

    Using the component:

    
    

提交回复
热议问题