uni-app

※前提条件:vue3 的uniapp开发

概要 [edit]

uni.setStorage的写法 [edit]

uni.setStorage({
		key: 'storage_key',
		data: {},
		success: () => {}
});

uni.setStorageSync的写法 [edit]

try {
		uni.setStorageSync(
			'storage_key',
			{},
		)
	} catch (e) {
	    // error
}

使用方法 [edit]

保存 [edit]

let items = JSON.stringify(数组或者对象);
uni.setStorageSync("wqzdy" , items);

取出

var data = uni.getStorageSync("wqzdy" );
var items = JSON.parse(data)

uni.navigateTo传递数组对象 [edit]

let items = JSON.stringify(item)
uni.navigateTo({
    url: '../order/refundMoney/refundMoney?item=' + items
})

取出

onLoad(e) { 
    this.item = JSON.parse(e.item)  
},

Troubleshooting [edit]

Uncaught Error: getStorageSync:fail parameter `key`. Expected String with value "undefined", got Undefined [edit]

原因是setStorageSync这个同步接口参数不是接收一个key,value形式的对象,而是两个参数,分别是key,value。


Comment:



(画像の文字列を入力して下さい)

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS