uni-app:第四章 網絡接口和其他

<template>
	<view>
		<view v-show="false">v-show</view>
		<view v-if="true">v-if</view>
		<view>xxx</view>
		<button type="primary" @click="toPath">路由跳轉</button>
		<view>
			<view>Vuex測試</view>
			<view>{{num}}</view>
			<button type="primary" @click="add">add方法</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			};
		},
		methods:{
			toPath(){
				uni.switchTab({
					url:"../index/index"
				})
			},
			add(){
				this.$store.commit("add")
			}
		},
		/**
		 * 計算
		 */
		computed:{
			num(){
				return this.$store.state.num;
			}
		},
		onLoad: () => {
			console.log("onLoad");
			uni.request({
			    url: 'https://bird.ioliu.cn/weather', //僅爲示例,並非真實接口地址。
			    data: {
			        city: '杭州'
			    },
			    header: {
			        'token': '123456' 
			    },
			    success: (res) => {
			        console.log(res.data);
			    }
			});
		},
		onReady() {
			console.log("onReady");
			console.log(this.$store.state.num)
		},
		onShow: () => {
			console.log("onShow");
		},
		onHide: () => {
			console.log("onHide");
		},
		onPullDownRefresh: () => {
			console.log("onPullDownRefresh");
		},
		onReachBottom: () => {
			console.log("onReachBottom");
		},
		onTabItemTap: () => {
			console.log("點擊 tab 時觸發,參數爲Object");
		}
		
	}
</script>

<style >

</style>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章