Uinapp

Uinapp调试关于手机版本号多次点击开启
然后在系统设置进行开发者模式配置
1.运行到小程序

manifest.json  添加小程序appid  
导航栏-工具-设置-运行设置-微信小程序安装路径

使用 Git 管理项目

在项目根目录中新建 .gitignore 忽略文件,并配置如下:
# 忽略 node_modules 目录
/node_modules
/unpackage/dist
打开终端,切换到项目根目录中,运行如下的命令,初始化本地 Git 仓库:
git init
将所有文件都加入到暂存区:
git add .
本地提交更新:
git commit -m "init project"

taber配置

{
	"pages": [{
		"path": "pages/home/home",  //路径
		"style": {
			"navigationBarTitleText": "标题",//单页面标题
			"enablePullDownRefresh": false,
			"navigationBarBackgroundColor": "#C00000",   单个导航栏背景颜色
			"navigationStyle":"custom"  //取消原生导航
		}

	}, {
		"path": "pages/cate/cate",
		"style": {
			"navigationBarTitleText": "标题",
			"enablePullDownRefresh": false
		}
	}, {
		"path": "pages/cart/cart",
		"style": {
			"navigationBarTitleText": "标题",
			"enablePullDownRefresh": false
		}
	}, {
		"path": "pages/my/my",
		"style": {
			"navigationBarTitleText": "标题",
			"enablePullDownRefresh": false
		}
	}],
	"tabBar": {
		"list": [{
				"pagePath": "pages/home/home",
				"text": "首页",    //taber底部文字
				"iconPath": "static/logo.png"  ,  //taber图标
				"iconPath": "static/logo.png"
			},
			{
				"pagePath": "pages/cate/cate",
				"text": "分类",
				"iconPath": "static/logo.png",
				"iconPath": "static/logo.png"
			},
			{
				"pagePath": "pages/cart/cart",
				"text": "购物车",
				"iconPath": "static/logo.png",
				"iconPath": "static/logo.png"
			},
			{
				"pagePath": "pages/my/my",
				"text": "我的",
				"iconPath": "static/logo.png",
				"iconPath": "static/logo.png"
			}
		]
	},
	"globalStyle": {
		"navigationBarTextStyle": "white",
		"navigationBarTitleText": "黑马优购",   
		"navigationBarBackgroundColor": "#C00000",   全局导航栏背景颜色
		"backgroundColor": "#FFFFFF"
	},
	"uniIdRouter": {}
}
uinapp跳转以及获取参数
第一种方法
uni.navigateTo({
		url: '/pages/index2/index2?id=1&name=uniapp'
});
onLoad: function(option) { //option为object类型,会序列化上个页面传递的参数
	console.log(option.id); //打印出上个页面传递的参数。
	console.log(option.name); //打印出上个页面传递的参数。
},
第二种方法
uni.navigateTo({
	url: '/pages/index2/index2?id=1&name=uniapp',
		events: {
		 // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
		 acceptDataFromOpenedPage: function(data) {
		   console.log(222222,data)
			  }
      },
});
onLoad: function(option) { //option为object类型,会序列化上个页面传递的参数
	console.log(option.id); //打印出上个页面传递的参数。
	console.log(option.name); //打印出上个页面传递的参数。
	const eventChannel = this.getOpenerEventChannel();
	eventChannel.emit('acceptDataFromOpenedPage', {id: 'data from test page'});
},

uniapp组件传值的方法(父传子,子传父,对象传值)案例

import phoneItem from '../../components/phoneItem.vue'
components: {
   Index2,
},
跟vue 一样

uinapp获取设置本地缓存

设置
uni.setStorage({
	key: 'storage_key',
	data: 'hello',
	success: function () {
		console.log('success');
	}
});
获取
uni.getStorage({
	key: 'storage_key',
	success: function (res) {
		console.log(res);
	}
});





{
	// 调试页面索引
	"condition": {
		//当前激活的模式(list 的索引项)
		"current": 0,
		"list": [{
			"name": "首页",
			"path": "pages/tab/index/index"
		},{
			"name": "个人中心",
			"path": "pages/tab/my/my"
		}]
	},
	//开启小程序按需注入
	"lazyCodeLoading":"requiredComponents",  
	// 主页配置
	"pages": [{
		// 首页
		"path": "pages/tab/index/index",
		"style": {}
	},{
		// 个人中心
		"path": "pages/tab/my/my",
		"style": {}
	}],
	// 分包配置
	"subPackages": [
		{
			// 登录分包,分包文件名称
			"root": "sub_intake",
			"name": "intake",
			"pages": [{
				// 登录
				"path": "pages/login/login",
				"style": {}
			},{
				//注册
				"path": "pages/register/register",
				"style": {}
			},{
				//忘记密码
				"path": "pages/forget/forget",
				"style": {}
			}]
		},
		{
			// 我的分包 my
			"root": "sub_my",
			"name": "my",
			"pages": [{
				// 修改信息
				"path": "pages/changeInfo/changeInfo",
				"style": {}
			},{
				// 修改密码
				"path": "pages/changePassword/changePassword",
				"style": {}
			},{
				// 设置
				"path": "pages/setting/setting",
				"style": {}
			}]
		}
	],
	// 分包预加载配置
	"preloadRule": {
		// 进入首页,预加载
		"pages/tab/index/index": {
			//在指定网络下预下载,可选值为:all(不限网络)、wifi(仅wifi下预下载
			"network": "all",
			//进入页面后预下载分包的 root 或 name。__APP__ 表示主包。
			"packages": ["my"]
		},
		// 进入我的后,预加载我的
		"pages/tab/my/my": {
			"network": "all",
			"packages": ["my"]
		}
	},
	"tabBar": {
		"list": [{
				"pagePath": "pages/tab/index/index",
				"iconPath": "/static/tabBar/home.png",
				"selectedIconPath": "/static/tabBar/home_blue.png",
				"text": "首页"
			},
			{
				"pagePath": "pages/tab/my/my",
				"iconPath": "/static/tabBar/user.png",
				"selectedIconPath": "/static/tabBar/user_blue.png",
				"text": "我的"
			}
		],
		"fontSize":"24upx",
		"iconWidth":"48upx",
		"spacing":"6upx",
		"height":"100upx",
		"color": "#999999",
		"selectedColor": "#593A25",
		"borderStyle": "white",
		"backgroundColor": "#fff"
	},
	//窗口全局样式
	"globalStyle": {
		// #ifdef MP-360
		"mp-360": {
			// 去掉uni-app header,使用360小程序header
			"navigationStyle": "custom" 
		},
		// #endif
		// #ifndef MP-TOUTIAO || MP-360
		"navigationStyle": "custom",
		"transparentTitle": "always",
		"navigationBarTextStyle": "white",
		// #endif
		"navigationBarTitleText": "移动开发框架",
		"navigationBarBackgroundColor": "#F8F8F8",
		"backgroundColor": "#EFEFF4"
		// 自动:auto / 竖屏:portrait / 横屏:landscape
		// "pageOrientation": "landscape"
	}
}

获取位置信息必须在manifest.json 里面设置地图相应的key
腾讯或者高德地图申请

 uni.chooseLocation({
		success: (res) => {
		console.log(res);
		console.log('位置名称:' + res.name);
		console.log('详细地址:' + res.address);
		console.log('纬度:' + res.latitude);
		console.log('经度:' + res.longitude);
	}
});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值