Merge pull request #2794 from trbrc/patch-1

Docs: Exporting function expression vs declaration
pull/2808/head
Rich Harris 6 years ago committed by GitHub
commit 9ba91ddcaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -48,10 +48,13 @@ Svelte uses the `export` keyword to mark a variable declaration as a *property*
// are immediately available
console.log(foo, bar);
// function declarations cannot be set externally,
// but can be accessed from outside
export function instanceMethod() {
alert(foo);
// Function expressions can also be props
export let format = (number) => (number.toFixed(2));
// Function declarations are added as methods
// on the component, rather than props
export function greetMethod() {
alert(`I'm a <${this.constructor.name}>!`);
}
// you can also use export { ... as ... } to have

Loading…
Cancel
Save