当前位置: 首页>>代码示例>>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;未经允许,请勿转载。