You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to set element's template directly in html file , but the properties and the others are set in js file like this:
html file:
"dom-example.html" 24L, 531C 22,21-22 All
<html>
<head>
<!-- Polyfills only needed for Firefox and Edge. -->
</head>
<body>
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@next/webcomponents-loader.js"></script>
<script type="module" src="./dom-ele.js">
</script>
<dom-module id="my-element">
<template>
<style>
.mood { color: green; }
</style>
<div>{{prop}}</div>
<p>
Web Components are <span class="mood">[[prop]]</span>!
</p>
</template>
</dom-module>
<my-element prop="OK"></my-element>
</body>
</html>
js file:
import {PolymerElement, html} from 'https://unpkg.com/@polymer/polymer@next/polymer-element.js?module';
class MyElement extends PolymerElement {
static get properties() { return { prop: String }}
}
customElements.define('my-element', MyElement);
The result is : when access html file in chrome, nothing showed.
I‘ve tried to move the dom-module's template into js file using "static get template() {...}", that's OK. But How can I set dom-module template in html no in js?
How can I fix this?
The text was updated successfully, but these errors were encountered:
As HTML Imports are deprecated as a browser feature, in Polymer 3 we no longer support authoring templates directly in HTML. There is no browser-native way to do this without a build step.
If all you want is to be able to author the HTML in html, at this point what you would need is a simple build-time transform that did something like this:
my-element.html
<!-- your template contents here -->
⬇️
my-element.html.js
import{html}from'@polymer/polymer-element.js';exportconsttemplate=html`<!-- your template contents here -->`;
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I want to set element's template directly in html file , but the properties and the others are set in js file like this:
html file:
js file:
The result is : when access html file in chrome, nothing showed.
I‘ve tried to move the dom-module's template into js file using "static get template() {...}", that's OK. But How can I set dom-module template in html no in js?
How can I fix this?
The text was updated successfully, but these errors were encountered: