若项目之前未使用npm管理依赖(项目根目录下无package.json文件),先在项目根目录执行命令初始化npm工程:
npm init -y
在项目根目录执行命令安装npm包:
npm install packageName --save
安装完即可使用npm包,js中引入npm包:
import package from 'packageName'
const package = require('packageName')
uni.switchTab({
url: '/pages/tabBar/component/component'
});
uni.setStorage({
key: 'launchFlag',
data: true,
});
https://uniapp.dcloud.io/api/storage/storage?id=getstoragesync
try {
const value = uni.getStorageSync('storage_key');
if (value) {
console.log(value);
}
} catch (e) {
// error
}