uni-base

2019-03-11  本文已影响0人  ddsfec

一、创建项目

使用脚手架的话 vue create -p dcloudio/uni-preset-vue my-project

二、生命周期

onLoad:function (option) {

//获取上个路由的传参

this.$data.id=option.id;

this.requestData();

},

mounted:function(){

//eventbus回调

bus.$on("call1",(message)=>{

this.showimg=message;

console.log(message);

});

//获取缓存

try {

                var value = uni.getStorageSync("jizhumima");

                if ("true"===value) {

this.param.username=uni.getStorageSync('mima_account');

this.param.password=uni.getStorageSync('mima_password');

        }else if("false"===value){

            }

            } catch (e) {

            console.log(value+'login。v 69line');

            }

}

三、条件渲染

//外层

<view v-for="(item,index) in bean.ui" :key='index' style="margin-bottom: 2upx;background: #FFFFFF;">

  <view class='layout' >

<view id="pointRoot">

<!-- 文本 -->

<text class='tv'>{{item.doc}}</text>

<!-- * -->

<text class='point' v-if="item.need">*</text>

</view>

<!-- 横输入框 -->

<input class="edit-hor" :placeholder="item.hint" v-model="item.value" v-if="item.orientation === orientation.horizontal"></input>

<!-- 单选 -->

<radio-group class='group' @change="radiochage($event ,item)">

//两层循环item不能都叫item

<label style="display: flex;"  v-for="(ritem, index2) in item.rGroup" :key="index2">

                    <view>

                        <radio  :value="ritem.v" :checked="ritem.v===item.value" />

                    </view>

                    <div style="white-space:nowrap; ">{{ritem.r}}</div>

                </label>

</radio-group>

</view>

<!-- 竖输入框 -->

<view style="background: #FFFFFF;" v-if="item.orientation === orientation.vertical">

<div style='height: 20upx; background: #FFFFFF;'></div>

    <input class="edit-ver" :placeholder="item.hint" v-model="item.value"  ></input>

        <div style='height: 20upx; background: #FFFFFF;'></div>

</view>

</view>

上一篇 下一篇

猜你喜欢

热点阅读