Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
Plain Vanilla JS + CapacitorJS

I’m a web developer and new to apps so excuse my ignorance and apologies if this is a stupid question.

I’ve setup a blank capacitorjs project, got all my emulators working (Android and iOS/Xcode) etc and now I cannot get the core plugins to work inside index.html.

Also when I include a locally hosted jQuery file in index.html I get localhost:// errors. Basically, not found.. for everything! When I link to the CDN it works.


My objective is to get my project to a blank slate where the index.html can make capacitor api calls eg alert(device info) etc. Any ideas where I am going wrong?

Index.html:

<script
  src="https://code.jquery.com/jquery-3.6.0.min.js"
  integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
  crossorigin="anonymous"></script>

  <script src="capacitor.js"></script>




<head></head>

<body>

<button id="button" style="width:500px; height:500px; background-color:gold;">TEST</button>


</body>


<script>

$("#button").on("click", (event) => {
  // execute your functions


const info = await Device.getInfo();
console.log(info);



  })


</script>

capacitor.config.json

import { Camera } from '@capacitor/camera';
import { CameraResultType } from '@capacitor/camera';
import { Device } from '@capacitor/device';

    const config: CapacitorConfig = {
  "appId": "com.zenithapp.app",
  "appName": "Zenith Mobile App",
  "webDir": "www",
  "bundledWebRuntime": true

};

export default config;

Result in XCODE console when compile and run my Capacitorjs app:

 ⚡️  ------ STARTUP JS ERROR ------

⚡️  SyntaxError: Unexpected identifier 'Device'. Expected ';' after variable declaration.
⚡️  URL: capacitor://localhost
⚡️  localhost:27:0

⚡️  See above for help with debugging blank-screen issues
⚡️  [error] - {"line":27,"sourceURL":"capacitor://localhost"}
⚡️  WebView loaded

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda