亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue 指令directive如何接受多個參數?

vue 指令directive如何接受多個參數?

慕哥9229398 2019-02-06 11:07:16
假設我有一個只能輸入數字的input,并且長度和小數點后位數有限制,那么我就需要兩個參數了,我該如何傳遞和指令里面獲取呢?下面是我傳遞一個參數或獲取的代碼,如下:<input type="text" v-spec-input='8'>directives: {    spec_input: {         bind: function (el, binding) {             //獲取             console.log(binding.value)         }     }, }
查看完整描述

2 回答

?
MYYA

TA貢獻1868條經驗 獲得超4個贊

<div v-demo="{ color: 'white', text: 'hello!' }"></div>

Vue.directive('demo', function (el, binding) {

  console.log(binding.value.color) // => "white"

  console.log(binding.value.text)  // => "hello!"

})


查看完整回答
反對 回復 2019-03-17
?
海綿寶寶撒

TA貢獻1809條經驗 獲得超8個贊

<input type="text" numberLength='8' pointLength='3'>
directives: {    spec_input: {
        bind: function (el, binding) {
            //獲取
            console.log(el.attributes.numberLength.value,el.attributes.pointLength.value )
        }
    },
}

這樣應該可以。


查看完整回答
反對 回復 2019-03-17
  • 2 回答
  • 0 關注
  • 1584 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號