Read a JS export

Asked

Viewed 28 times

0

How can I read an export, this giving me the following message:

Uncaught Referenceerror: Timecontroller is not defined

in the HTML this:

 <script src="./js/controllers/TimeController.js"></script>
    <script>
        let timeController = new TimeController();
    </script>

in my Timecontroller.js this as

import {TimeView} from '../views/TimeView';
import {Time} from '../models/Time';
import {Colaborador} from '../models/Colaborador';

export class TimeController {

     constructor() {
        this._inputNome = $('#InputNome');
         this._inputNick = $('#InputNick');

       this._timeView = new TimeView($('#timeView'));
     }

     adicionaTime(event) {
        // faz algo
     }
}

package json.

{
  "name": "",
  "version": "2.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha",
    "start": "parcel serve index.html -p 8080",
    "build": "parcel build index.html"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.3.1",
    "bootstrap": "^4.1.3",
    "eslint": "^4.13.1",
    "eslint-config-google": "^0.9.1",
    "firebase": "^5.5.4",
    "firebase-tools": "^6.5.2",
    "handlebars": "^4.1.1",
    "jquery": "^3.3.1",
    "mocha": "^5.1.1",
    "node-sass": "^4.9.3",
    "parcel-bundler": "^1.12.3",
    "popper.js": "^1.14.3",
    "pug": "^2.0.3",
    "typescript": "^3.0.3"
  },
  "dependencies": {
    "bootstrap-social": "^5.1.1",
    "jsdom": "^14.0.0"
  }
}

1 answer

0

Do it this way

<script>
  import {TimeController} from './js/controllers/TimeController';

  let timeController = new TimeController();
</script>
  • I put it in the home.html /home.html:1:29: Imports and requires are not supported Inside inline <script> tags yet. > 1 | import {Timecontroller} from './js/controllers/Timecontroller' | 2 | Let timeController = new Timecontroller();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.