Home > Web Front-end > uni-app > body text

How to load json file in uni-app

藏色散人
Release: 2023-01-13 00:44:42
Original
8206 people have browsed it

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
}
Copy after login

3, uni-app page introduction

<script>
    import sortdata from '../../data/sortData.js'
    export default {
        data() {
            return {
                list: sortdata
            }
        }
    }
</script>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template