Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
How to call a function bundled with webpack with external javascript?

How to call a function bundled with webpack with external javascript?

The webpack.js file consists of:

const init = (inputUrl) => {
    // window.onload = function(){
    init.loadMap = function(inputUrl){
        const wrap = document.querySelector('#px');
        Px.Core.Initialize(wrap, function(){
          Px.Loader.LoadFbx({
          // url: '../src/model/Bumma_004/Bumma_004.FBX',
          url: inputUrl,
            onLoad: function(){
              console.log("FBX Loading Complete");
              console.log(inputUrl);
            }
          })
        })
    }
    init.getconfig = function getconfig(){
        return url;
    }
    // init.getconfig = getconfig;

    function test(msg){
        return console.log('test function completed ' + msg);
    }
    init.test = test;
// }
}
export default init;

The index.js file is composed as follows.

import init from './temp.js'

init.loadMap('abc');

After bundling webpack.js, I want to put another url in index.js in init.loadMap and output to html.

However, in the index.js file, Cannot use import statement outside a module occurs on the first line.

How can I solve this problem?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

fixed using global.init = init

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda