Vue 取得本地json值

嗯..一开始是想让 vue 路由直接返回json,不过好像有点难,
如果是直接用xhr还好说,直接拿过来就行

这里说的是本地的,根据stackoverflow上的是,将变量从另一个js引入

json.js

export const jsonInput = [
  { id: "1", title: "Mars" },
  { id: "2", title: "Venus" },
  { id: "3", title: "Pluto" }
];

Hello.vue

然后就能引用jsondata的数据了(也就是在jsonInput里的数据)

参考:
https://stackoverflow.com/questions/46699064/returning-json-with-vue-router


已发布

分类

,

来自

标签:

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注