原生微信小程序注意事項
原生小程序的新建文件
步驟一:打開app.json全局配置文件可以看到page字段里的內容,直接寫,自動新建
"pages": [
"pages/index/index",
]
原生小程序修改值 this.({})
注意,一旦你的數據想要渲染到wxml文件中,展示在頁面上,就得通過({})
this.data.xxx
如果只是js文件中的調用,就不需要上面那個方法進行運算
1, this.({})
2,注意:this.里面不能判斷條件
一、使用[‘字符串’]形式
this.setData({
['steps[0].text']:“哈哈”
})
二、使用’字符串’形式
this.setData({
'steps[0].text':“哈哈”
})
三、構造變量,重新賦值
這個就是定義新的中間變量,接收修改后的值,然后再把中間變量給之前的值
var steps= this.data.ordersteps
steps[0].text= ‘哈哈’
this.setData({
ordersteps:steps
})
原生小程序修改按鈕樣式
微信客服按鈕去掉邊框的方式:
方法1:
button::after {
border: none;

}
方法2:
先給加一個plain屬性
<button class="contact" plain @tap="tocontact" open-type="contact">聯系客服</button>
然后找到按鈕的樣式加上這行代碼
button[plain]{ border:0 }
原生父傳子注意事項:
提示:這里填寫問題的分析:
//父傳
<workbench data="{{work}}" status="{{work.status}}"></workbench>
//子收
properties: {
status:{type:String},
data:{type:Object}

},
//打印,直接接收可能收不到,得定時器
created() {
setTimeout(() => {
this.setData({
detail:this.properties.data
})
console.log(this.data.detail)
}, 100)
},
原生小程序組件的引用
步驟一:.json文件的引用
{
//這個
"usingComponents": {
"tabbar":"/components/tabbar/tabbar",
},

"navigationStyle":"custom",
"navigationBarBackgroundColor": "#f43022",
"disableScroll":true
}
步驟二微信小程序判斷字符串,頁面直接使用
<tabbar></tabbar>
原生小程序使用vant組件的van-無遮罩:
發現無背景遮罩微信小程序判斷字符串,解決方法,采用vant組件的van-popup包裹van-:
<van-popup
show="{{ isShowState }}"//控制彈窗的彈起和關閉
round
position="bottom"
bind:close="onClose"
>
<van-picker show-toolbar="{{true}}" bind:cancel="onCancel" bind:confirm="conFirmstateList" columns="{{ stateList }}" />
</van-popup>

原生小程序自定義頂部
步驟一:文件的.json里面
{
"usingComponents": {},
"navigationStyle":"custom"
}
步驟二:.wxml里面,我
<van-nav-bar border="{{false}}" custom-style="background:#f5f7fb">
//左箭頭
<van-icon name="arrow-left" bindtap="onClickLeft" color="#000" size="20px" slot="left" />
//自定義的輸入框,一般沒這個需求
<view class="popSearchTop" slot="left">
<van-search left-icon="/xxx/search.png" value="{{ search_val }}" placeholder="請輸入" background="#fff !important" shape="round" bind:change="inputSearch" bind:search="onSearch" clearable="{{false}}" placeholder-style="color:rgba(13,16,19,0.6);width:120%">
</van-search>
</view>
</van-nav-bar>