Home >Web Front-end >uni-app >How to load json file in uni-app

How to load json file in uni-app

藏色散人
藏色散人Original
2021-09-11 11:39:358258browse

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.

How to load json file in uni-app

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn