vue create meituan
安装 node-sass和sass-loader,而后在style标签中添加lang属性,就能够在style标签中使用sass语法来愉快的写css了css
npm install node-sass@4.12.0 --save-devhtml
npm install sass-loader@8.0.0 --save-devvue
<style lang="scss"> @import "styles/init.css"; </style>>
安装2个包 postcss-pxtorem 和 lib-flexible,而后在package.json中添加配置文件就能够使用了node
npm install postcss-pxtorem --save-dev
npm install lib-flexible --save-dev
配置npm
“postcss": {
"plugins": {
"autoprefixer": {},
"postcss-pxtorem": {
"rootValue ": 37.5,
"propList": [
"*"
],
"selectorBlackList": [
"van-*"
]
}
}
}
在main.js中导入使用json
import "lib-flexible"
安装2个包 babel-plugin-import 和 vant 而后在babel.config.js中配置canvas
// 安装
npm install babel-plugin-import --save-dev
npm install vant --save
// 配置
module.exports = {
plugins: [
['import', {
libraryName: 'vant',
libraryDirectory: 'es',
style: true
}, 'vant']
]
}sass
新建个init.css文件为了初始化html标签的属性,放在全局的css样式中ruby
init.css文件内容babel
a, abbr, acronym, address, applet, article, aside, audio, b, big, blockquote, body, canvas, caption, center, cite, code, dd, del, details, dfn, div, dl, dt, em, embed, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, html, i, iframe, img, ins, kbd, label, legend, li, mark, menu, nav, object, ol, output, p, pre, q, ruby, s, samp, section, small, span, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, time, tr, tt, u, ul, var, video { margin: 0; padding: 0; border: 0; font-family: "PingFangSC-Regular", Hiragino Sans GB, Arial, Helvetica, "\5B8B\4F53", sans-serif;}
新建Home.vue
<template> <div class="Home"> <h1>这是首页</h1> </div> </template> <script> export default { name: "Home", data : function () { return { } } } </script> <style> </style>
在App.vue中导入使用
<template> <div id="app"> <Home></Home> </div> </template> <script> import Home from "./components/Home" export default { name : "app", components : { Home } } </script> <style lang="scss"> @import "styles/init.css"; </style>>
效果图以下