Nuxt 引入三方组件

引入第三方组件

Element-ui

/plugins/element-ui.js

1
2
3
4
5
6
7
import Vue from 'vue'
import Element from 'element-ui/lib/element-ui.common'
import locale from 'element-ui/lib/locale/lang/en'

export default () => {
Vue.use(Element, {locale})
}

nuxt.config.js

1
2
3
4
5
6
7
8
module.exports = {
plugins: [
'@/plugins/element-ui'
],
css: [
'element-ui/lib/theme-default/index.css'
]
}

VueAwesomeSwiper

/plugins/swiper.js

1
2
3
4
import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper/ssr'

Vue.use(VueAwesomeSwiper)

nuxt.config.js

1
2
3
4
5
6
7
8
module.exports = {
plugins: [
{src: '~/plugins/swiper.js', ssr: false},
],
css: [
'swiper/dist/css/swiper.css'
]
}