From novice to familiar with using uni-app to guide learning documents

1: Create a new uni-app
2: Run through the h5 page, WeChat applet, and your own mobile phone.
Three: Project catalog
Insert picture description here

pages: store each page component
static: store static resources
unpackage: exist here after packaging
App.vue: root file
main.js: main entry file
manifest.json: some app configuration
pages.json: store page path (style) and global Path (style)
uni.scss: built-in style

Four: understand the style on the official website
Five: configure tabbar (style reference document)
If the application is a multi-tab application, you can specify the performance of the tab bar through the tabBar configuration item, and the corresponding page displayed when the tab is switched. (List has at least two items)
Insert picture description here

Insert picture description here

Insert picture description here
Insert picture description here

Six: Condition startup mode configuration The
startup mode configuration takes effect only during the development period and is used to simulate the scene of a direct page, such as: after a small program is forwarded, the user clicks on the opened page.
Insert picture description here

Insert picture description here

Seven: Components: uni-app provides a wealth of basic components for developers. Developers can combine various components like building blocks to form their own applications. (Rich components, understand the official documents)
Insert picture description here

text text component
Insert picture description here
Insert picture description here

view(=div)

Insert picture description here
Insert picture description here

button (rich attributes, refer to official documents)

Insert picture description here
Insert picture description here

Media component image

Insert picture description here
Insert picture description here

Eight: the style in uni-app

Insert picture description here
Insert picture description here

The way to introduce css:
1 directly in the component page

Introduce icon font chart:
1 Introduce folder fonts in static
Insert picture description here

2 Introduce
@import url("./static/fonts/iconfont.css") in App.vue public style ;

3 Modify the path in the iconfont.css file

Add the original path: ~@/static/fonts/
Insert picture description here

4 reference in view: iconfont must be

Insert picture description here

Import scss files:
1 Download scss compilation plugin
2 Tab

Nine: Data binding (similar to Vue99%)

Insert picture description here
Insert picture description here

Ten: Life Cycle

Insert picture description here

Insert picture description here
Insert picture description here

Pull-down refresh: onPullDownRefresh (belonging to the life cycle function)
defines the onPullDownRefresh processing function in js (at the same level as onLoad and other life cycle functions), and listens to the user pull-down refresh event of the page.

1 First give pull-down refresh permission in json
Insert picture description here

2 Monitor pull-down refresh: (action triggered by pull-down refresh)
Insert picture description here

3 uni.stopPullDownRefresh stop refresh

4 Pull down refresh can be triggered by button

Insert picture description here

Bottom loading new content: onReachBottom

Insert picture description here

Can be configured in json, how far from the bottom to trigger the bottom loading function:
Insert picture description here

Attached

Insert picture description here

Eleven: network request (get)

Insert picture description here
Insert picture description here

Insert picture description here

Twelve: Data Cache
1 Set click event to trigger uni.setStorage; uni.getStorage; uni.removeStorage to store separately; query; delete data.
2 The browser searches in the Local Storage of the Application; the WeChat applet searches in the Storage.

Insert picture description here

Insert picture description here

Thirteen: Upload pictures (refer to official documents)
Insert picture description here

1 Trigger the uni.chooseImage function to upload an image by clicking the event
2 this.imgArr = res.tempFilePaths assign the image address to the image array
3 v-for loop to render the image
Insert picture description here

preview picture
Insert picture description here

Insert picture description here

Fourteen: conditionally compiled cross-terminal compatible
html content:
Insert picture description here

Cross-terminal compatibility of js content:
Insert picture description here

Cross-terminal compatibility of css content:
Insert picture description here

Fifteen: Navigation Jump in Uni
Declarative Navigation
Insert picture description here

Programmatic navigation
Insert picture description here
Insert picture description here

Navigation parameters:
directly after the address (?id=80&page=1). The web page that accepts the parameters receives the parameters in the onload.
Insert picture description here

Attachment: open-type attribute: the way to jump to the page (declarative jump)

Insert picture description here

Sixteen: The creation of components in uni-app (same as vue)
The life cycle functions of components are the same as vue
1 beforeCreate
2 create
3 beforeMount
4 mount
5 beforeUpdate
6 update
7 beforeDestroy
8 destroy
Insert picture description here

Seventeen: Communication of uni-app components The
parent passes values ​​to the child:
1 The child component binds data in the parent component
Insert picture description here

2 The child component receives the data of the parent component through props:[''}
Insert picture description here

The child passes the value to the parent component:
1 The child component calls the method through the click event:
Insert picture description here

2 In the method this.$emit('myEven', this.num): trigger the myEven of the parent component and pass data
3 The parent component receives data:
Insert picture description here

Insert picture description here

Value passing between sibling components
a ----> b
1 a component triggers events globally and passes parameters through uni.$emit
Insert picture description here

2 The b component listens globally through uni.$on and receives parameters (in the created() method)
Insert picture description here

Eighteen: uni ui extension components
Insert picture description here

1 download
2 import
3 register
4 call method (just copy the code and paste)
Insert picture description here

Guess you like

Origin blog.csdn.net/MJ1314MJ/article/details/109011211