我有這樣一個vuejs組件(map.vue
):導入腳本錯誤的命令,函數沒有定義
<script>
import '../../assets/js/map.js'
export default {
name: 'home',
data() {
return {
init_data: {},
}
},
created: function() {
this.init_data = window.get_init_data(this.view, function(response) {
document.title = response.body.page_title;
init_map(some_arguments);
});
}
}
</script>
map.js:
const key = ******;
function init_map(some_args) {
...
}
錯誤:
[Vue warn]: Error in created hook: "ReferenceError: init_map is not defined"
而且實際上,在源代碼簽名之前檢查它被調用的函數。
注意:我不想在webpack條目中包含map.js
,因爲我只需要在一個組件中使用此腳本(map.vue
)。
試試'。 require('../../ assets/js/map.js')' –
已經做了@Ole gShleif,問題依然存在。謝謝 –
這不難解釋如何? –