Skip to content

Instantly share code, notes, and snippets.

@jsmithdev
Created May 30, 2019 03:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsmithdev/53e2bcdbd077f7e2fed5ee8a0ee1924f to your computer and use it in GitHub Desktop.
Save jsmithdev/53e2bcdbd077f7e2fed5ee8a0ee1924f to your computer and use it in GitHub Desktop.
LWC test of loading style from resource; style.css is uploaded as a static resource named style
.target {
min-width: 300px;
min-height: 300px;
background: blue !important;
color: white !important;
}
<template>
<h3>{header}</h3>
<div class="target">
Bleep bloop
</div>
</template>
/* eslint-disable no-console */
import { api, LightningElement } from 'lwc';
import { loadStyle } from 'lightning/platformResourceLoader';
import styles from '@salesforce/resourceUrl/style';
export default class TestStyle extends LightningElement {
@api header
renderedCallback() {
console.log('styles')
console.log(styles)
loadStyle(this, styles)
.then(() => console.log('Files loaded.'))
.catch(error => console.log("Error " + error.body.message))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment