本文整理匯總了TypeScript中vue.use函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript use函數的具體用法?TypeScript use怎麽用?TypeScript use使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了use函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: require
(function () {
var Vue = require('vue')
if (!Vue) {
var message = 'Vue not installed'
alert(message)
throw new Error(message)
}
Vue.use(require('../../src'))
})()
示例2: default
export default ({ env }) => {
Vue.use(VueGoogleMaps, {
load: {
key: env.GOOGLE_MAPS_API_KEY,
libraries: 'places',
language: 'en'
}
})
}
示例3: before
before(() => {
Vue.use(VueRouter)
directiveTest = new ComponentTest('<div><navbar></navbar><router-view>loading...</router-view></div>', { 'navbar': MockNavbarComponent })
let homeComponent = { template: '<div class="home">Home</div>' }
let aboutComponent = { template: '<div class="about">About</div>' }
let listComponent = { template: '<div class="list">List</div>' }
router = new VueRouter({
routes: [
{ path: '/', component: homeComponent },
{ path: '/about', component: aboutComponent },
{ path: '/list', component: listComponent }
]
})
})
示例4: function
run: function (app) {
Vue.config.debug = true;
Vue.config.async = false;
Vue.use(VueRouter);
Vue.component('vue-logo', vueLogo);
Vue.component('materialize-logo', materializeLogo);
Vue.component('doc-api', docApi);
Vue.component('doc-sources', docSources);
Vue.component('doc-snippet', docSnippet);
Vue.component('doc-tabs', docTabs);
var router = new VueRouter({
history: false,
root: '/'
});
router.map(mapping);
router.start(App, app);
},
示例5:
// https://vuex.vuejs.org/zh-cn/intro.html
// make sure to call Vue.use(Vuex) if using a module system
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex as any)
const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment: (state) => {
const obj = state
obj.count += 1
},
decrement: (state) => {
const obj = state
obj.count -= 1
}
}
})
export default store
示例6:
import vuexI18n, { i18nState } from "vuex-i18n";
// declare interface for store's root state
interface RootState {
i18n: i18nState;
}
// initialize the vuex store using the vuex module. note that you can change the
// name of the module if you wish
const store = new Store<RootState>({});
// initialize the internationalization plugin on the vue instance. note that
// the store must be passed to the plugin. the plugin will then generate some
// helper functions for components (i.e. this.$i18n.set, this.$t) and on the vue
// instance (i.e. Vue.i18n.set).
Vue.use(vuexI18n.plugin, store);
// please note that you must specify the name of the vuex module if it is
// different from i18n. i.e. Vue.use(vuexI18n.plugin, store, "myName")
// add some translations (could also be loaded from a separate file)
// note that it is possible to use placeholders. translations can also be
// structured as object trees and will automatically be flattened by the the
// plugin
const translationsEn = {
content: "This is some {type} content",
tree: {
nested: "This is nested content"
}
};
示例7:
import Vue from 'vue';
import VueScrollActive from 'vue-scrollactive';
Vue.use(VueScrollActive);
export default {};
示例8: random
/// <reference types="../../node" />
const assert = console.assert;
const random = () => Math.trunc(Math.exp(Math.log(Date.now()) * Math.random()));
import * as Vue from 'vue';
import * as VueI18n from 'vue-i18n';
import { ComponentOptions } from 'vue';
/**
* VueI18n.install
*/
Vue.use(VueI18n);
VueI18n.install(Vue);
/**
* VueI18n.version
*/
assert(typeof VueI18n.version === 'string');
/**
* VueI18n Instance
*/
const locale = random().toString();
const key = `_${random()}`;
const value = `${random()}|${random()}|${random()}`;
const i18n = new VueI18n({
locale,
fallbackLocale: locale,
messages: {
[locale]: {
示例9: createPersistedState
import institution from "./modules/institution";
import search from "./modules/search";
import transcript from "./modules/transcript";
const modules = {
authentication,
calendar,
filter,
institution,
search,
transcript
};
const PRODUCTION = process.env.NODE_ENV === "production";
Vue.use(Vuex);
const plugins = [
createPersistedState({
paths: Object.keys(modules).filter(m => m != "institution")
})
];
if (PRODUCTION) {
LogRocket.init("e5pnvu/can-i-graduate");
plugins.push(
createLogRocket(LogRocket, mutation => {
if (mutation.type == "authentication/update") {
return {
type: mutation.type,
payload: {
示例10: Vue
import './css/site.css';
import 'bootstrap';
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
const routes = [
{ path: '/', component: require('./components/home/home.vue.html') },
{ path: '/work', component: require('./components/work/work.vue.html') },
{ path: '/aboutme', component: require('./components/aboutme/aboutme.vue.html') }
];
new Vue({
el: '#app-root',
router: new VueRouter({ mode: 'history', routes: routes }),
render: h => h(require('./components/app/app.vue.html'))
});