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


TypeScript vue.mixin函數代碼示例

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


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

示例1: function

  }

})()


Vue.mixin({
  created: function () {
    //console.log('mixin hook created called')
  },
  
  compiled: function () {
    if ($ && $.parser){
        $.parser.parse(this.$el);
    }
  },
  attached:function(){
    //console.log("attached");
  },
  dettached:function(){
    //console.log("dettached");
  },
  
  destroy:function(){
    //console.log("called destroyed");
  }
});

//e.g.
// new Vue({
//       el:'#app',
//       data:{
開發者ID:noteon,項目名稱:vue-easyui,代碼行數:31,代碼來源:ezModel.ts

示例2: function

 registerMixins: function () {
     for (var i = 0; i < mixins.length; i++) {
         Vue.mixin(mixins[i]);
     }
 },
開發者ID:Pandahisham,項目名稱:material-components,代碼行數:5,代碼來源:index.ts

示例3: function

 const factory = function(Component: Function, options?: any): void {
   Vue.mixin(BuildOptions(Component, options) as any)
 }
開發者ID:budiadiono,項目名稱:vue-typed,代碼行數:3,代碼來源:mixins-global.ts

示例4: require

Vue.use(Element, { locale: elementLocale });

// Register global directives
require('./common/views/directives');

// Register global components
require('./common/views/components');
require('./common/views/widgets');

// Register global filters
require('./common/views/filters');

Vue.mixin({
	destroyed(this: any) {
		if (this.$el.parentNode) {
			this.$el.parentNode.removeChild(this.$el);
		}
	}
});

/**
 * APP ENTRY POINT!
 */

console.info(`Misskey v${version} (${codename})`);
console.info(
	'%c%i18n:common.do-not-copy-paste%',
	'color: red; background: yellow; font-size: 16px; font-weight: bold;');

// BootTimer解除
window.clearTimeout((window as any).mkBootTimer);
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:31,代碼來源:init.ts

示例5: api

		const launch = (router: VueRouter, api?: (os: MiOS) => API) => {
			os.apis = api ? api(os) : null;

			//#region Dark/Light
			Vue.mixin({
				data() {
					return {
						_unwatchDarkmode_: null
					};
				},
				mounted() {
					const apply = v => {
						if (this.$el.setAttribute == null) return;
						if (v) {
							this.$el.setAttribute('data-darkmode', 'true');
						} else {
							this.$el.removeAttribute('data-darkmode');
						}
					};

					apply(os.store.state.device.darkmode);

					this._unwatchDarkmode_ = os.store.watch(s => {
						return s.device.darkmode;
					}, apply);
				},
				beforeDestroy() {
					this._unwatchDarkmode_();
				}
			});

			os.store.watch(s => {
				return s.device.darkmode;
			}, v => {
				if (v) {
					document.documentElement.setAttribute('data-darkmode', 'true');
				} else {
					document.documentElement.removeAttribute('data-darkmode');
				}
			});
			//#endregion

			Vue.mixin({
				data() {
					return {
						os,
						api: os.api,
						apis: os.apis
					};
				}
			});

			const app = new Vue({
				store: os.store,
				router,
				render: createEl => createEl(App)
			});

			os.app = app;

			// マウント
			app.$mount('#app');

			return [app, os] as [Vue, MiOS];
		};
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:65,代碼來源:init.ts

示例6: created

Vue.mixin({
  created() {
    const vm = this;
    let obs = vm.$options.subscriptions;
    if (typeof obs === "function") {
      obs = obs.call(vm);
    }
    if (obs) {
      const keys = Object.keys(obs);
      keys.forEach(key =>
        (Vue as any).util.defineReactive(
          vm,
          key,
          undefined /* val */,
          null /* customSetter */,
          true /* shallow */
        )
      );
      vm._subscriptions = keys.map(key => {
        return (obs[key] instanceof Observable
          ? obs[key]
          : of(obs[key])
        ).subscribe(value => (vm[key] = value));
      });
    }
  },

  beforeDestroy() {
    if (this._subscriptions) {
      this._subscriptions.forEach(handle => handle.unsubscribe());
    }
  }
});
開發者ID:kevmo314,項目名稱:canigraduate.uchicago.edu,代碼行數:33,代碼來源:main.ts

示例7: require

import Vue         from 'vue';
import VeeValidate from 'vee-validate';

Vue.use(VeeValidate);

const $style: any = require('identity-obj-proxy');

(HTMLCanvasElement as any).prototype.getContext = () => {
  return;
};

(global as any).CLIENT = true;
(global as any).SERVER = true;
(global as any).TEST = true;

Vue.config.productionTip = false;

Vue.mixin({
            created() {
              this.$style = $style;
            },
          });
開發者ID:trungx,項目名稱:vue-starter,代碼行數:22,代碼來源:jestsetup.ts

示例8: created

  if (title) {
    const target = __SERVER__ ? vm.$ssrContext : document
    target.title = `${TITLE} | ${title}`
  }
}

Vue.mixin(
  __SERVER__
    ? {
        created() {
          setTitle(this)
        },
      }
    : {
        watch: {
          '$t.locale'() {
            setTitle(this)
          },
          '$tt.loading'(loading) {
            if (!loading) {
              setTitle(this)
              this.$forceUpdate()
            }
          },
        },
        mounted() {
          setTitle(this)
        },
      },
)
開發者ID:JounQin,項目名稱:blog,代碼行數:30,代碼來源:title.ts

示例9: get

Object.defineProperties(Vue.prototype, {
  $bus: {
    get() { return this.$root.bus; }
  },
  $authenticated: {
    get() { return this.$root.authenticated; },
    set(a) { this.$root.authenticated = a; }
  }
});


// TODO inject at a module level...?
// AudioContext Mixin: all Components will have access to AudioContext
Vue.mixin({
  data() {
    return { context };
  }
});


// Global Components (inlets / outlets)
Vue.component('inlets', inlets);
Vue.component('outlets', outlets);


new Vue({
  store,
  data: {
    bus: new Vue(),
    authenticated: false
  },
開發者ID:apathetic,項目名稱:modular-synth,代碼行數:31,代碼來源:main.ts

示例10: Vue

import Vue from "vue";
import VueRouter from "vue-router";
import AsyncComputed from 'vue-async-computed';
import { router } from './router';
import GlobalMixin from './GlobalMixin';
import genericAttr from './attrs/genericAttr.vue';

import "./filters/various";
import "./directives/various";
import "./directives/validators";
import "./directives/Bootstrap";
import "./directives/typeahead";

Vue.mixin(GlobalMixin);
Vue.use(VueRouter)
Vue.use(AsyncComputed)
Vue.component('genericAttr', genericAttr); // make it global to break circular dependency

new Vue({ 
    router
}).$mount(".page");
開發者ID:prigaux,項目名稱:compte-externe,代碼行數:21,代碼來源:main.ts


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