This is the second day of my participation in Gwen Challenge
1. Jump to a page (note that the path is configured in pages. Json)
// If you jump from A to B, you can go back to A via the phone's back button, which means a exists in the history
uni.navigateTo({
url:`/pages/garbage/appointmentRecovery/record/cancelOrderparams=The ${JSON.stringify(this.formData)}`
});
// Close the current page and jump to a page in the app. The current page cannot be returned by using the back button.
uni.redirectTo({
url: 'test? id=1'
});
// return to the previous page
uni.navigateBack()
// Jump to the tabBar page and close all other non-Tabbar pages.
uni.switchTab({
url: '/pages/index/index'
});
// Close all pages to open a page within the app.
uni.reLaunch({
url: 'test? id=1'
});
Copy the code
2. Get the URL pass parameter in the onLoad life cycle
Note: onLoad is the life cycle of uniApp and only runs once when the page loads
onLoad(params) {
console.log(params.params)
}
Copy the code
3. UI used with UNIAppuView
4. Unique conditional compilation
#ifndef: if defined exists only on the platform #ifndef: if not defined exists only on the platform
5. Use the camera function
/* Call the camera code */
uni.chooseImage({
count: 1.sizeType: ['original'.'compressed'].sourceType: ['camera'].success: res= > {
const tempFilePaths = res.tempFilePaths[0]; }});Copy the code
6. Preview images
previewImage(index) {
// Preview the image
uni.previewImage({
urls: this.imgUrl,
current: this.imgUrl[index]
});
},
Copy the code
7. Open the map and select a location.
uni.chooseLocation({
success: res= > {
const {address,name,latitude,longitude} = res
}
});
Copy the code
8. Hide app native navigation – configured in pages. Json
"path": "pages/mapVehicle"."style": {
"app-plus": {
"titleNView": false}}Copy the code
9. Set the app navigation bar – in pages. Json
"path": "pages/login/login"."style": {
"navigationBarTitleText": "Login"
}
Copy the code
10. Get the current location and speed.
uni.getLocation({
type: 'wgs84'.success: function (res) {
console.log('Longitude of current position:' + res.longitude);
console.log('Latitude of current position:'+ res.latitude); }});Copy the code
Note: Appkey needs to be filled in the SDK configuration of the MANIFEST for cloud packaging, and can be configured in the native project for offline packaging. Notice The package name, AppKey, and certificate information must match. The real machine can be located normally, because the real machine running base uses the SDK configuration that DCloud applies to Gaud, which must be applied by the developer himself after packaging.