赞
踩
<template>
<view class="home-wrap">
首页{{store.state.user.name}}
<view @click="goDetailHandle('ok')">查看详情</view>
<mz-item-line name='gsddgsgds'></mz-item-line>
</view>
</template>
<script setup>
import {
ref,
reactive,
getCurrentInstance
} from "vue"
import {
useStore
} from "vuex";
/**
* 在 Vue3 组合式 API 中,也需要遵循 uni-app 生命周期钩子规范,
* **/
import {
onLoad,
onShow,
onPullDownRefresh,
onReachBottom
} from "@dcloudio/uni-app"
const {
appContext
} = getCurrentInstance();
const store = useStore();
console.log("[miao]", store.state.user.name);
/**
* 接口请求参数
* **/
const queryObject = reactive({
limit: 10,
page: 1,
keyword: ""
})
console.log(queryObject)
initFunction(queryObject);
/**
* 监听页面加载
* **/
onLoad((options) => {
console.log("[options]", options)
queryObject['page'] = 2;
initFunction(queryObject);
});
/**
* 监听页面显示,页面每次出现在屏幕上都会触发
* **/
onShow(() => {
console.log("[onShow]")
});
/**
* 监听用户下拉动作
* **/
onPullDownRefresh(() => {
console.log("ok")
queryObject['page'] = 3;
initFunction(queryObject);
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1000)
});
/**
* 上拉加载更多:页面滚动到底部触发事件
* **/
onReachBottom((e) => {
console.log("[上拉加载更多]")
queryObject['page'] = 4;
initFunction(queryObject);
})
/**
* 初始化页面
* **/
function initFunction(params) {
console.log("[asd]", params)
}
/**
* 查看详情
* **/
function goDetailHandle(row) {
console.log(row, appContext.config.globalProperties.$http)
console.log(uni.$miao)
uni.navigateTo({
url: "/pages/detail/detail?id=123&code=m"
})
}
</script>
<style lang="scss" scoped>
.home-wrap {
border: 1px solid red;
width: $mzWidth;
margin: 12px auto;
display: flex;
flex-direction: column;
min-height: 1200px;
}
</style>
<template>
<view>
</view>
</template>
<script setup>
/**
* 在 Vue3 组合式 API 中,也需要遵循 uni-app 生命周期钩子规范,
* **/
import {
onLoad,
onShow,
onPullDownRefresh,
onReachBottom
} from "@dcloudio/uni-app"
onLoad((options)=>{
console.log("[ options]",options)
})
</script>
<style lang="scss" scoped>
</style>
import App from './App'
import store from "./store"
import {
createSSRApp
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.config.globalProperties.$http = 'miao'
uni.$miao = 'mzz'
app.use(store)
return {
app
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。