-
<script src="WordData.json" type="text/javascript">
</script>
导入WordData.json,然后t1:JSON.parse(text)
名为text的JSON对象,转换为文本放在t1里。
想取name值可以用:t1.employees[0].name 这样来取
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://unpkg.com/vue/dist/vue.js"></script> <script src="http://google.github.io/traceur-compiler/bin/traceur.js" type="text/javascript"></script> <script src="http://google.github.io/traceur-compiler/src/bootstrap.js" type="text/javascript"></script> <script src="WordData.json" type="text/javascript"></script> <script> traceur.options.experimental = true; </script> <title>Document</title> </head> <body> <div id="app"> <p>{{ t1 }}</p> <p>{{ t1.employees[0].name }} </p> </div> <script> new Vue({ el: '#app', data: { t1:JSON.parse(text) } }) </script> </body> </html>