簡體   English   中英

Uncaught ReferenceError: “function” is not defined ES6 模塊

[英]Uncaught ReferenceError: “function” is not defined ES6 Modules

我正在嘗試使用 ES6 模塊,但 html 似乎無法識別我的事件。


export function weatherCardCreator() {
    const cardContainer = document.querySelector('.card-container');
    const localStorageCities = dbManipulator.readData('Cities');
    let weatherCards = localStorageCities && localStorageCities.map(
        (weatherCard, weatherIndex) => `
            <div class="card" onclick="renderWeatherOnOneCityOnClick(${weatherIndex})">
                <div class="card-halfwayup">
                    <div class="flex-left">

export function renderWeatherOnOneCityOnClick(weatherItemKey)

您沒有提供您的導入語句,但您需要使用單個導入

import thingYouAreImporting from 'path-to-js-file-with-export';

為了從另一個文件訪問它。 對於從具有多個導出的文件導入,

import { thing1, thing2 } from 'path-to-js-file-with-exports';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM