Nuxt 使用感悟2

使用第三方组件

全部页面都使用,在nuxt.config.js添加plugins,当然首先要安装element

head: {
title: ‘首页’,//process.env.npm_package_name || ‘’,
meta: [
{ charset: ‘utf-8’ },
{ name: ‘viewport’, content: ‘width=device-width, initial-scale=1’ },
{ hid: ‘description’, name: ‘description’, content: process.env.npm_package_description || ‘’ }
],
link: [
{ rel: ‘icon’, type: ‘image/x-icon’, href: ‘/favicon.ico’ },
{ rel: ‘stylesheet’, href: ‘/css/common.css’ }
]
},
/*
** Global CSS
*/
css: [
‘element-ui/lib/theme-chalk/index.css’
],
plugins: [
‘@/plugins/element-ui’
],

单个页面使用

import elementui from ‘element-ui’;

动态引入组件

    <keep-alive>
    <component :is="componentname"></component >
    </keep-alive>

components:{
sale1:() => import(’~/components/sale1’),
sale2:() => import(’~/components/sale2’)
}
能减少初进入系统的加载时间,起码看起来快了

修改化页面的头部

head:{
  title:"工具",
  link: [
  { rel: 'icon', type: 'image/x-icon', href: '/logo.png' }
  ]

},

页面异步加载信息

async asyncData(){
let page=0
let {data}=await axios.get(/api/config) //异步函数运行到await就会返回,返回值是Promise
return {myconfig: data} //Vue会将这个加到data
} ,
东西太多,没法一下子全写,以后吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值