How to load json files in uni-app: 1. Create a new folder and put the data into js; 2. Pass "import sortdata from '../../data/sortData.js'. .." method to introduce the json file into the uni-app page.
The operating environment of this article: windows7 system, uni-app version 2.5.1, DELL G3 computer.
How does uni-app load json files?
uni-app imports local json data into the page and uses
1. In the project root folder, first create a new folder and then throw the data into js
2, js
let data = { //这里放数据 } module.exports = { data: data }
3, uni-app page introduction
<script> import sortdata from '../../data/sortData.js' export default { data() { return { list: sortdata } } } </script>
Recommended: "uniapp tutorial"
The above is the detailed content of How to load json file in uni-app. For more information, please follow other related articles on the PHP Chinese website!