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>>
效果圖以下