當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vue.directive函數代碼示例

本文整理匯總了TypeScript中vue.directive函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript directive函數的具體用法?TypeScript directive怎麽用?TypeScript directive使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了directive函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

(()=>{
  let vueIf=Vue.directive('if');

  let oldInsert=vueIf.insert;

  vueIf.insert=function(){
    oldInsert.apply(this);
    $ && this.frag && this.frag.node && $.parser && this.vm && $.parser.parse(this.frag.node);
  }

})()
開發者ID:noteon,項目名稱:vue-easyui,代碼行數:11,代碼來源:ezModel.ts

示例2: setTimeout

Vue.directive('ez-model', {
  twoWay: true,
  priority: 1000,

  isFirstCall:true,

  params: ['options'],

  ezClass: "",
    
  initEasyUiComp:function(value){
    let self = this;
    let $el=$(self.el);
    let options=this.params.options || {};

    let oldOnChange=options.onChange;
    options.onChange=function (newVal,_oldVal) {
       if (oldOnChange)
           oldOnChange.apply(this,arguments);

       self.set(newVal);
    }

    this.ezClass=(()=>{
       let cls=$el.attr('class').split(/\s+/).find((it)=>it.indexOf("easyui-")===0);
       return cls.split('-').slice(1).join('-');      
    })(); 
    if (this.ezClass==="datebox" || this.ezClass==="datetimebox"){
       $el[this.ezClass](options);

       setTimeout(()=>this.trySetValue(value,true),0);

       return;  
    }
    
    if (this.ezClass==="calendar"){
      options.current=value;
    }else if (this.ezClass==="switchbutton"){
      options.checked=value;
    } else {
      options.value=value;
    }

    $el[this.ezClass](options);

  },


   trySetValue: function(value,ignoreMultiple){
    let self=this;
    let $el= $(self.el);

    let isMultipleValues=ignoreMultiple?false:!!$el[this.ezClass]("options").multiple;

    let setValMethod=isMultipleValues?"setValues":"setValue";

    if (self.ezClass==="calendar"){
          setValMethod="moveTo";
      }

      try {
        if (self.ezClass==="datebox"){
            value=value && moment(value).format('M/D/Y')
        }else if (self.ezClass==="datetimebox"){
            value=value && moment(value).format('M/D/Y HH:mm:ss')
        }

         $el[this.ezClass](setValMethod, value);
      } catch (error) {
        console.error(error);
      }
  },

  bind: function () {
  },

  update: function (value) {
    if (this.isFirstCall){
       this.isFirstCall=false;
       this.initEasyUiComp(value);
    }else{
      this.trySetValue(value);
    }

  },
  unbind: function () {
    $(this.el)[this.ezClass]('destroy')
  }
})
開發者ID:noteon,項目名稱:vue-easyui,代碼行數:89,代碼來源:ezModel.ts

示例3: bind

import * as Stickyfill from "stickyfilljs";
import Vue from "vue";

export default Vue.directive("stickyfill", {
  bind(el: HTMLElement) {
    el.style.position = "sticky";
    el.style.top = "75px";
    Vue.nextTick(() => Stickyfill.add(el));
  },
  unbind(el: HTMLElement) {
    Stickyfill.remove(el);
  }
});
開發者ID:kevmo314,項目名稱:canigraduate.uchicago.edu,代碼行數:13,代碼來源:Sticky.ts

示例4:

import Vue from 'vue';

import autocomplete from './autocomplete';

Vue.directive('autocomplete', autocomplete);
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:5,代碼來源:index.ts

示例5: loadScriptOnce

    let params = { select, wsParams: { allowInvalidAccounts: true } };
    let searchURL = conf.wsgroupsURL + '/searchUserCAS';

    loadScriptOnce(conf.wsgroupsURL + "/web-widget/autocompleteUser-resources.html.js", (err) => {
        if (err) {
            console.error(err);
        } else {
            window['jQuery'](this.$el)['autocompleteUser'](searchURL, params);
        }
    });
  },
})

Vue.directive('auto-focus', {
    inserted(el : HTMLElement) { 
        el.focus();
    }
})

// emits 'change' event
Vue.component('input-file', {
    template: "<input @change='read' type='file'>",
    methods: {
        read: function (e) {
            this.$emit('change', e.target.files[0] as File);
        },
    },
});

// usage: v-on-submit.prevent="action" where "action" returns a promise
//
開發者ID:prigaux,項目名稱:compte-externe,代碼行數:31,代碼來源:various.ts

示例6: function

 registerDirectives: function () {
     for (var directiveName in directives) {
         Vue.directive(directiveName, components[directiveName]);
     }
 },
開發者ID:Pandahisham,項目名稱:material-components,代碼行數:5,代碼來源:index.ts

示例7: bind

import Vue, { DirectiveOptions } from "vue";

const AsyncBind: DirectiveOptions = {
  bind(el, binding) {
    bind(el, binding.value);
  },
  update(el, binding) {
    bind(el, binding.value);
  }
};

function bind(el: HTMLElement, binding: Promise<string>) {
  if (binding) {
    Promise.resolve(binding).then(value => {
      el.innerHTML = value;
    });
  }
}

Vue.directive("async-bind", AsyncBind);
開發者ID:pranavjindal999,項目名稱:Youtube-Material,代碼行數:20,代碼來源:AsyncBind.ts

示例8:

import Vue from 'vue';

import userPreview from './user-preview';

Vue.directive('userPreview', userPreview);
Vue.directive('user-preview', userPreview);
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:6,代碼來源:index.ts

示例9: Vue

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import placehold from './directive/placehold'
import './registerServiceWorker'

Vue.config.productionTip = false

Vue.directive('src', placehold)

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
開發者ID:cbcruk,項目名稱:mrpizzacn,代碼行數:16,代碼來源:main.ts

示例10: inserted

import Vue, { DirectiveOptions, VNodeDirective } from "vue";

const SyncWidth: DirectiveOptions = {
  inserted(el, binding) {
    bind(el, binding);
  }
};

function bind(el: HTMLElement, binding: VNodeDirective) {
  el.style.maxWidth =
    (binding.value * document.getElementById(binding.arg)!.clientWidth) / 100 +
    "px";
}

Vue.directive("sync-width", SyncWidth);
開發者ID:pranavjindal999,項目名稱:Youtube-Material,代碼行數:15,代碼來源:SyncWidth.ts


注:本文中的vue.directive函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。