当前位置:网站首页>Uni app Foundation
Uni app Foundation
2022-06-13 02:40:00 【And white】
Directory structure

New interface

// After the new page is created, if you are in page.json There is no corresponding interface declaration in Please be there. pages Inside plus
{
"path": "pages/index/index",// The path of the page
"style": {
"navigationBarTitleText": " children APP", // Top title
"enablePullDownRefresh": false,// Enable pull-down refresh
"app-plus": {
"titleNView": false // Do not use the system top navigation bar
}
}
},
uniApp All in the interface div Have been replaced by view

uniapp Page supported lifecycles
The screenshot here is only part of You can check it here
https://uniapp.dcloud.io/collocation/frame/lifecycle?id=page

created stay vue Can be supported in But in uniapp I only support onload
Interface jump
// Similar to an applet
uni.navigateTo({
url: '/pages/index/index',
success: res => {
},
fail: () => {
},
complete: () => {
}
});
//vue
this.$router.push('/pages/index/index')
//router Jump
this.$route({
url: 'pages/index/index'
})
Interface value transfer ( Just like a small program )
uni.navigateTo({
// It can also be in url Intermediate direct value transfer
url:'/pages/niceServeDetail/niceServeDetail?id=666',
// Receive the value from the second interface
events: {
// Add a listener... For the specified event , Get the data transferred from the opened page to the current page
acceptDataFromOpenedPage: function(data) {
console.log(data)
},
someEvent: function(data) {
console.log(data)
}
},
success: (res) => {
// Transfer values to the second interface
res.eventChannel.emit("title","titleContent")
// The second interface transfers values to the first interface
eventChannel.emit('acceptDataFromOpenedPage', {
data: 'data from second page'});
eventChannel.emit('someEvent', {
data: 'data from second page for someEvent'});
}
})
// In the second interface onload In the receiving
onload(option){
console.log(" Here is url Transmitted value ->",option.id);
// #ifdef APP-NVUE
const eventChannel = this.$scope.eventChannel; // compatible APP-NVUE
// #endif
// #ifndef APP-NVUE
const eventChannel = this.getOpenerEventChannel();
// #endif
eventChannel.on("title",(res)=>{
console.log(" The value received ->",res);
})
}
Play the news ( It is surprisingly similar to an applet )
uni.showToast({
title: 'msg',
icon:'none',
mask:false,// Similar to transparent mask effect , Click to penetrate
});
Using third party dependencies
Follow vue It's the same
// For example, add dependencies uni-ui
npm i uni-ui -S
Network request
uni.request({
url:"url",
data:" Request parameters ",
method:"GET",
success: (e) => {
//TODO
},
fail: (e) => {
}
})
Pull up to refresh Pull down load
// Pull down data refresh Need to open "enablePullDownRefresh": true,
// Drop down listening function
onPullDownRefresh() {
},
// Bottom function That is, pull up the monitor stay vue Life cycle function peers in the interface
onReachBottom() {
}
Bottom navigation bar settings

vuex Use vuex Official website
stay uniApp Built in vuex We just need to configure it
// stay index In file
// Page path :store/index.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);//vue Plug in mechanism of
//Vuex.Store Constructor options
const store = new Vuex.Store({
state:{
// Storage status
"username":"foo",
"age":18
}
})
export default store
### stay main.js Inject... Into the file
// Page path :main.js
import Vue from 'vue'
import App from './App'
import store from './store'
Vue.prototype.$store = store // Setting global $store object
// hold store The object is provided to “store” Options , This can store All the subcomponents are injected with the instance of
const app = new Vue({
store,
...App
})
app.$mount()
Use
this.$store.state.username // Can get
vuex Zhongduo module Under the circumstances state obtain
//this.$store.state. The name of the warehouse .prop
this.$store.state.mineStore.isLogin
边栏推荐
- [reading paper] generate confrontation network Gan
- Mean Value Coordinates
- too old resource version,Code:410
- [deep learning] fast Reid tutorial
- Vant框架中关于IndexBar索引栏的CDN单页面引用,无法正常展示
- Understand speech denoising
- 微信云开发粗糙理解
- Model prediction of semantic segmentation
- 小程序 input,textarea组件权重比fixed的z-index都高
- [reading point paper] deeplobv3 rethinking atlas revolution for semantic image segmentation ASPP
猜你喜欢

After idea uses c3p0 connection pool to connect to SQL database, database content cannot be displayed

Principle and steps of principal component analysis (PCA)

How did you spend your winter vacation perfectly?

Chapter7-11_ Deep Learning for Question Answering (2/2)

Chapter7-10_ Deep Learning for Question Answering (1/2)

Vant框架中关于IndexBar索引栏的CDN单页面引用,无法正常展示
![[data and Analysis Visualization] D3 introductory tutorial 1-d3 basic knowledge](/img/a8/468a0c4d4a009e155679898fac4b81.jpg)
[data and Analysis Visualization] D3 introductory tutorial 1-d3 basic knowledge
![PCR validation of basic biological experiments in [life sciences]](/img/92/1cecb7cb4728937bd18b336ba4e606.jpg)
PCR validation of basic biological experiments in [life sciences]

Detailed explanation of handwritten numeral recognition based on support vector machine (Matlab GUI code, providing handwriting pad)
![[reading papers] deepface: closing the gap to human level performance in face verification. Deep learning starts with the face](/img/e4/a25716ae7aa8bdea64eb9314ca2cc7.jpg)
[reading papers] deepface: closing the gap to human level performance in face verification. Deep learning starts with the face
随机推荐
regular expression
Paper reading - group normalization
05 tabbar navigation bar function
[data analysis and visualization] key points of data drawing 6- too many data groups
A real-time target detection model Yolo
02 optimize the default structure of wechat developer tools
Linear, integer, nonlinear, dynamic programming
Leetcode 473. Match to square [violence + pruning]
01 initial knowledge of wechat applet
Paper reading - beat tracking by dynamic programming
Opencvshare4 and vs2019 configuration
[data and Analysis Visualization] data operation in D3 tutorial 3-d3
[reading paper] generate confrontation network Gan
How to learn to understand Matplotlib instead of simple code reuse
Detailed explanation of data processing in machine learning (I) -- missing value processing (complete code attached)
05 tabBar导航栏功能
在IDEA使用C3P0連接池連接SQL數據庫後卻不能顯示數據庫內容
Ffmpeg principle
Priority queue with dynamically changing priority
Chapter7-11_ Deep Learning for Question Answering (2/2)