1.index.html
<view>
<textarea placeholder='参数' bindinput='searchTxt'></textarea>
<button bindtap='saveTxt'>存入参数</button>
</view>
2.index.js
var app =getApp()
Page({
/**
* 页面的初始数据
*/
data: {
txt:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/*获取输入框的值 */
searchTxt:function(e){
console.log(e.detail.value)
var _this=this;
_this.setData({
txt.detail.value
})
},
/**保存参数 */
saveTxt:function(){
try{
wx.setStorageSync('txt', this.data.txt)
}catch(e){
}
wx.showLoading({
title: '哈哈哈',
})
wx.navigateTo({
url: '../storage/storage',
})
},
})
3.storage.html
<view>
<text>storage:{{storage}}</text>
</view>
4.storage.js
var app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
storage:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this=this;
//获取数据
wx.getStorage({
key: 'infofrominput',
success: function(res) {
_this.setData({
storage:res.data
})
},
})
},
})