4.6 KiB
4.6 KiB
title |
---|
快速上手 |
安装
npm install mand-mobile --save
引入
按需加载(推荐)
// .babelrc
{
plugins: [
[import, {
libraryName: "mand-mobile"
}]
]
}
// ts-loader option
{
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
transpileOnly: true,
getCustomTransformers: () => ({
before: [
require('ts-import-plugin')({
"libraryName": "mand-mobile"
})
]
})
}
}
]
}
组件使用:
import { Button } from 'mand-mobile'
按需引入
import Button from 'mand-mobile/lib/button'
全量引入
import Vue from 'vue'
import mandMobile from 'mand-mobile'
Vue.use(mandMobile)
使用前准备
px
to rem
组件样式以px
为单位,并且以iPhone6
屏幕 “物理像素” 宽度750
为基准 (即普通 “逻辑像素” 值的2
倍大小)。在实际项目中,可根据具体情况使用postcss-pxtorem
把px
单位转成rem
,从而实现不同设备下等比缩放的效果。
如转换基准为1rem = 100px
:
webpack
配置
const pxtorem = require('postcss-pxtorem');
// postcss
webpackConfig.postcss.push(pxtorem({
rootValue: 100,
propWhiteList: []
}))
// poststylus
const poststylus = require('poststylus')
webpackConfig.plugins.push(new webpack.LoaderOptionsPlugin({
options: {
stylus: {
use: [
poststylus(pxtorem({
rootValue: 100,
propWhiteList: []
}))
]
}
}
}))
- 或
.postcssrc.js
配置
module.exports = {
'plugins': [
require('postcss-pxtorem')({
rootValue: 100,
propWhiteList: []
})
]
}
使用
这是一个使用Mand Mobile
组件开发而成的表单页面,更多的组件使用方法可在组件概览中找到。
<template>
<div id="app">
<md-field title="投保人" class="block">
<md-input-item
title="投保人姓名"
placeholder="请填写投保人姓名"
></md-input-item>
<md-input-item
title="身份证号"
placeholder="请填写投保人身份证号"
></md-input-item>
</md-field>
<md-field title="被保人" class="block">
<md-input-item
title="被保人姓名"
placeholder="请填写被保人姓名"
></md-input-item>
<md-field-item
title="与投保人关系"
arrow="arrow-right"
:value="relation"
@click="isPickerShow = true"
solid
></md-field-item>
<md-picker
v-model="isPickerShow"
:data="pickerData"
title="选择与投保人关系"
></md-picker>
<md-input-item
title="身份证号"
placeholder="请填写被保人身份证号"
></md-input-item>
<md-input-item
title="手机号"
type="phone"
placeholder="请填写被保人手机号"
></md-input-item>
</md-field>
<md-agree class="agree">
本人承诺投保人已充分了解本保险产品,并保证投保信息的真实性,理解并同意
</md-agree>
<md-action-bar :actions="actionBarData">
¥128.00
</md-action-bar>
</div>
</template>
<script>
import {
Agree,
ActionBar,
Field,
FieldItem,
InputItem,
Picker
} from 'mand-mobile'
export default {
name: 'app',
components: {
[Agree.name]: Agree,
[ActionBar.name]: ActionBar,
[Field.name]: Field,
[FieldItem.name]: FieldItem,
[InputItem.name]: InputItem,
[Picker.name]: Picker
},
data () {
return {
relation: '本人',
isPickerShow: false,
actionBarData: [{
text: '我要投保'
}],
pickerData: [[{text:'本人'},{text:'父母'},{text:'配偶'},{text:'子女'}]]
}
}
}
</script>
<style>
* {
margin: 0;
padding: 0;
}
body{
background: #f0f0f0;
}
.detail{
background: #fff;
font-size: .24rem;
}
.block{
margin-top: .32rem;
}
.agree{
padding: .32rem;
font-size: .24rem;
color: #666;
}
</style>