使用Handlebars和Node.js / Express导入/导出实现

时间:2018-11-20 18:54:30

标签: javascript node.js express

我正在尝试使用带有nodejs / express的把手来实现导入/导出。由于某种原因,它给了我以下错误[the-O,user-O,@-O,enter-O,log-c1,=-O,to-O,validate-O,log entrie-c2,in-O,,a-O,log entrie block-c3]

enter image description here

文件-api.js

Uncaught SyntaxError: Unexpected token {

文件-fetchData.js

import { getSymbolDb, executeEnterKey } from './fetchData'

const symbolTags = document.querySelector('#symbolTags')
const requestSymbol = document.querySelector('#requestSymbol')
requestSymbol.addEventListener('click', getSymbolDb)
symbolTags.addEventListener("keyup", executeEnterKey)
document.addEventListener('DOMContentLoaded', getSymbolDb)

HTML文件

export function getSymbolDb() {}
export function executeEnterKey(event) {}

1 个答案:

答案 0 :(得分:0)

解决方案

Here,您将找到有关该主题的更多信息。以下代码是您可以开始使用的基本示例。

文件-api.mjs

import { getSymbolDb, executeEnterKey } from './fetchData.mjs'

const symbolTags = document.querySelector('#symbolTags')
const requestSymbol = document.querySelector('#requestSymbol')
requestSymbol.addEventListener('click', getSymbolDb)
symbolTags.addEventListener("keyup", executeEnterKey)
document.addEventListener('DOMContentLoaded', getSymbolDb)

文件-fetchData.mjs

export function getSymbolDb() {}
export function executeEnterKey(event) {}

HTML文件

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>


</head>

<body>

  {{{body}}}


  <script type="module" src="/JS/api.mjs"></script>
  <script nomodule src="fallback.js"></script>


</body>

</html>