|
|
@ -48,10 +48,13 @@ Svelte uses the `export` keyword to mark a variable declaration as a *property*
|
|
|
|
// are immediately available
|
|
|
|
// are immediately available
|
|
|
|
console.log(foo, bar);
|
|
|
|
console.log(foo, bar);
|
|
|
|
|
|
|
|
|
|
|
|
// function declarations cannot be set externally,
|
|
|
|
// Function expressions can also be props
|
|
|
|
// but can be accessed from outside
|
|
|
|
export let format = (number) => (number.toFixed(2));
|
|
|
|
export function instanceMethod() {
|
|
|
|
|
|
|
|
alert(foo);
|
|
|
|
// 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
|
|
|
|
// you can also use export { ... as ... } to have
|
|
|
|