1,下载flexible.js
可加载阿里的cdn文件 http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js
或者将下载好的文件放到static也就是静态资源文件中
2,下载postcss-px2rem
npm install --save postcss-px2rem
3,配置nuxt.cofig.js
在head里加上
script: [
{ src: '/rem/flexible.js', type: 'text/javascript', charset: 'utf-8'}
],
在build里加上
postcss: [
require('postcss-px2rem')({
remUnit: 75
})
],
完整的nuxt.config.js
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
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' }
],
script: [
{ src: '/rem/flexible.js', type: 'text/javascript', charset: 'utf-8' }
],
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
'element-ui/lib/theme-chalk/index.css',
{src:'~assets/css/index.scss',lang:'scss'}
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'@/plugins/element-ui'
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
],
/*
** Nuxt.js modules
*/
modules: [
],
/*
** Build configuration
*/
build: {
extractCSS: { allChunks: true },
transpile: [/^element-ui/],
postcss: [
require('postcss-px2rem')({
remUnit: 75
})
],
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
}
}
配置成功:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。