1. h5請求中包含小程序跳轉(zhuǎn)
$.ajax({
url: '/me/editinfo',
type: 'POST',
dataType: 'json',
data: {
avatar: _avatar,
nick: _nick,
sex: _sexy,
birthday: _birthday,
phone: _phone,
email: _email
}
})
.done(function(json) {
layer.closeAll();
if (json.success) {
layer.msg('修改成功',1,1);
// 小程序跳回
if(window.__wxjs_environment === 'miniprogram'){
wx.miniProgram.switchTab({
url: '/pages/me'
})
} else {
_back && _back == 'memberCenter' ? _back = _back+'?layerType=1' : null;
_back ? location.href = '/'+_back : null;
}
}else{
layer.msg('請求失敗矗漾,請重試',1,3);
};
})
.error(function(json) {
layer.msg('請求失敗,請重試',1,3);
});
2 .小程序原生彈層
wx.showModal()
3. 路由跳轉(zhuǎn)復用同一組件
路由跳轉(zhuǎn)復用同一組件:由于組件已經(jīng)渲染過一次,參數(shù)改變不會被重新渲染母债,所以調(diào)用beforeRouteUpdate
重新渲染組件
https://router.vuejs.org/zh/guide/advanced/navigation-guards.html#組件內(nèi)的守衛(wèi)
beforeRouteUpdate (to, from, next) {
// 在當前路由改變,但是該組件被復用時調(diào)用
// 舉例來說概页,對于一個帶有動態(tài)參數(shù)的路徑 /foo/:id敬尺,在 /foo/1 和 /foo/2 之間跳轉(zhuǎn)的時候,
// 由于會渲染同樣的 Foo 組件留搔,因此組件實例會被復用更胖。而這個鉤子就會在這個情況下被調(diào)用。
// 可以訪問組件實例 `this`
},
4. ivew表格
columns
定義表格的列數(shù)據(jù)
data
定義表格的行數(shù)據(jù)
border
表格行的邊框線
<template>
<Table width="550" border :columns="columns2" :data="data3"></Table>
</template>
<script>
export default {
data () {
return {
columns: [
{
title: 'Name',
key: 'name',
width: 100,
fixed: 'left'
},
{
title: 'Age',
key: 'age',
width: 100
},
{
title: 'Province',
key: 'province',
width: 100
},
{
title: 'City',
key: 'city',
width: 100
},
{
title: 'Address',
key: 'address',
width: 200
},
{
title: 'Postcode',
key: 'zip',
width: 100
},
{
title: 'Action',
key: 'action',
fixed: 'right',
width: 120,
// 定義某一列包含多個按鈕隔显,使用render函數(shù)
render: (h, params) => {
return h('div', [
h('Button', {
props: {
type: 'text',
size: 'small'
}
}, 'View'),
h('Button', {
props: {
type: 'text',
size: 'small'
}
}, 'Edit')
]);
}
}
],
data: [
{
name: 'John Brown',
age: 18,
address: 'New York No. 1 Lake Park',
province: 'America',
city: 'New York',
zip: 100000
},
{
name: 'Jim Green',
age: 24,
address: 'Washington, D.C. No. 1 Lake Park',
province: 'America',
city: 'Washington, D.C.',
zip: 100000
},
{
name: 'Joe Black',
age: 30,
address: 'Sydney No. 1 Lake Park',
province: 'Australian',
city: 'Sydney',
zip: 100000
},
{
name: 'Jon Snow',
age: 26,
address: 'Ottawa No. 2 Lake Park',
province: 'Canada',
city: 'Ottawa',
zip: 100000
}
]
}
}
}
</script>