html文件:
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div id="app">
    <ul>
        <li>名称: {{info.name}}</li>
        <li>年龄: {{info.age}}</li>
        <li><a v-bind:href="info.url">{{info.url}}</a></li>
    </ul>
</div>

<!-- 生产环境版本,优化了尺寸和速度 -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<!--引入Axios-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data() {
            return {
                info: {
                    name: "",
                    age: ""
                }
            }
        },
        mounted() {
            axios.get("data.json")
                .then(response => this.info = response.data)
        }
    });
</script>
</body>
</html>
json文件——data.json
{
  "name": "张三",
  "age": "12",
  "url": "https://www.baidu.com"
}
Logo

前往低代码交流专区

更多推荐