打开edit.vue页面,先贴代码
edit.vue
<template>
<view class="body">
<!-- 显示区正式开始 -->
<view class="myfrom">
<form @submit="goLink">
<textarea class="mytext" maxlength="-1" v-model="desc" placeholder="请输入文本" auto-height
adjust-position />
<view class="mybutton">
<button type="primary" formType="submit">保存</button>
</view>
</form>
</view>
<!-- 显示区结束 -->
</view>
</template>
<script>
var _self, loginUID;
var noteID, index;
export default {
data() {
return {
desc: ''
}
},
methods: {
goLink() {
uni.request({
url: _self.apiServer + 'edit',
method: 'POST',
header: {'content-type': "application/x-www-form-urlencoded"},
data: {
'uid': loginUID,
'ID': _self.noteID,
'txt': _self.desc
},
success: res => {
//console.log(res);
uni.showToast({title: "修改成功",icon: "none"});
// 带参数返回
uni.$emit('bindex', {
'id': _self.index,
'newtxt': _self.desc
});
uni.navigateBack();
}
});
} //golink
},
onLoad: function(option) {
_self = this;
loginUID = _self.checkLogin('/index/index');
if (!loginUID) {
return;
} else(console.log(loginUID));
//以下是读取内容
this.noteID = opti