use*_*629 1 javascript json vue.js nuxt.js vuetify.js
我试图动态构建一个nuxt项目vuetify组件(使用与vuetify成分不同的文本值由模块在进口和迭代通过JSON()https://hackernoon.com/import-json-into-typescript-8d465beded79)。
我在 /static/info.json 中的 json 是:
{
"id": 1,
"name": "Johnson, Smith, and Jones Co.",
"amount": 345.33,
"Remark": "Pays on time"
}
Run Code Online (Sandbox Code Playgroud)
在我的 vue 组件中,我有:
import * as data from '../static/info.json';
const word = data.name;
console.log(word); // output 'testing'
console.log(data); // output 'testing'
var jsonData = JSON.parse(data);
// console.log(jsonData); // output 'testing'
Run Code Online (Sandbox Code Playgroud)
线路:
var jsonData = JSON.parse(data);
Run Code Online (Sandbox Code Playgroud)
原因:
Cannot convert object to primitive value
Run Code Online (Sandbox Code Playgroud)
如何遍历导入的 json?
归档时间: |
|
查看次数: |
3177 次 |
最近记录: |