Your cart is currently empty!
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
发表回复