https://github.com/mohrtw/NuxtLoadLibraryOnClient/tree/master
我们导入的库未在客户端上加载。
在objectProcessor
中放置调试器表明服务器上加载了正确的数据,
但是导入的SO和OO对象是未定义的,因此它不能通过instanceOf检查并返回"没有工作"
组件/ util的/ objectLoader.vue :
```
<template>
<div>
<h1>from objectLoader</h1>
<h2>Object data: {{objectProcessor(obj)}}</h2>
</div>
</template>
<script>
import SO from '../../static/someObjects';
import OO from '../../static/otherObjects';
//debugger;
export default {
props: ['obj'],
methods: {
objectProcessor: function (obj) {
/* returns a name or title depending
on the type of object
*/
var result = '';
debugger; // eslint-disable-line
if (obj instanceof SO.AnObject) {
result = obj.name;
console.log(result);
} else if (obj instanceof OO.AnotherObject) {
result = obj.title;
} else {
result = 'didn\'t work';
}
return result;
}
}
}
</script>
```