简体   繁体   中英

How to use LWC as web components in HTML/JavaScript apps without a server like node

I'm creating desktop and web apps as pure HTML+JavaScript and recently started using Web Components, as discussed here: How to run web components based HTML without node?

And here: How to run Polymer locally, without any web server?

I would like to do the same with LWC components and be able to include them in basic HTML/JS apps, without using node. I guess that potentially this can be done by replacing "import { LightningElement } from 'lwc'" with some external JavaScript files?

Any simple example would be appreciated - thanks!

I received a response from LWC development team, as follows:

" LWC components must be compiled by the LWC compiler before they can be run, so no, you cannot directly import LWC source files in the browser and use them in the browser. However, you can use the CustomElementConstructor API to import a compiled LWC component just like any other web component. Here is a demo: https://github.com/nolanlawson/lwc-barebone/tree/7e3662b7a86aa1f1ca2e0b39c2696057d3495519/src

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM