svelte

export typescript type in svelte file

偶尔善良 提交于 2021-01-04 05:33:36
问题 I want to export the type that I defined in one of my files and import it inside another file. export type myNewType = {name: string}; linter show me bellow error when I add export : Modifiers cannot appear here. I can make it work by creating a new ts file and import the type from it. I just want to know if there is a way to define type inside svelte file or not. Update: I use the sapper template and it will run without error but TS functionality not work and show me errors in vscode when

export typescript type in svelte file

China☆狼群 提交于 2021-01-04 05:32:06
问题 I want to export the type that I defined in one of my files and import it inside another file. export type myNewType = {name: string}; linter show me bellow error when I add export : Modifiers cannot appear here. I can make it work by creating a new ts file and import the type from it. I just want to know if there is a way to define type inside svelte file or not. Update: I use the sapper template and it will run without error but TS functionality not work and show me errors in vscode when

How to marry this todo list with instant search in Svelte?

那年仲夏 提交于 2020-12-15 04:44:05
问题 EDIT for the tldr version scroll down to where it says I'm extremely close in the code below. Problem I have a basic todo list that when completed will have these qualities: When the page loads the form field should be in focus. When the user clicks the up/down arrows the items in the list should be selected via a CSS background color change. When the user types a new item into the form it should appear in the list to the user. When the user types into the form field, an "instant search" is

How to marry this todo list with instant search in Svelte?

瘦欲@ 提交于 2020-12-15 04:43:48
问题 EDIT for the tldr version scroll down to where it says I'm extremely close in the code below. Problem I have a basic todo list that when completed will have these qualities: When the page loads the form field should be in focus. When the user clicks the up/down arrows the items in the list should be selected via a CSS background color change. When the user types a new item into the form it should appear in the list to the user. When the user types into the form field, an "instant search" is

Svelte user registration issue with setting store value

醉酒当歌 提交于 2020-12-12 14:25:08
问题 helo :) I'm trying to register an user and after success, setContext to newly registered user and then navigate to home. Server properly responds and registers user, but when setContext is called i get the following error: "index.mjs:552 Uncaught (in promise) Error: Function called outside component initialization" <script> import { setContext } from 'svelte' async function handleRegistration(e) { let user = { firstname: e.target.firstname.value, lastname: e.target.lastname.value, } fetch(

Svelte user registration issue with setting store value

人走茶凉 提交于 2020-12-12 14:21:26
问题 helo :) I'm trying to register an user and after success, setContext to newly registered user and then navigate to home. Server properly responds and registers user, but when setContext is called i get the following error: "index.mjs:552 Uncaught (in promise) Error: Function called outside component initialization" <script> import { setContext } from 'svelte' async function handleRegistration(e) { let user = { firstname: e.target.firstname.value, lastname: e.target.lastname.value, } fetch(

Svelte user registration issue with setting store value

对着背影说爱祢 提交于 2020-12-12 14:21:09
问题 helo :) I'm trying to register an user and after success, setContext to newly registered user and then navigate to home. Server properly responds and registers user, but when setContext is called i get the following error: "index.mjs:552 Uncaught (in promise) Error: Function called outside component initialization" <script> import { setContext } from 'svelte' async function handleRegistration(e) { let user = { firstname: e.target.firstname.value, lastname: e.target.lastname.value, } fetch(

Failing to generate dynamic routes with Sapper export

邮差的信 提交于 2020-12-12 10:00:10
问题 I have a dynamic route: routes/artwork/[slug].svelte . All works great with npm run dev . But when I npm run export those dynamic slug routes are missing. I don't see them in the __sapper__/export , and the pages are missing as well when I uploaded to Netlify. Any clue how I might be able to fix that? Did I miss something obvious? 回答1: sapper export works by building your app, running it, then visiting / and recursively visiting every internal link it finds. For that reason, it has to be

Implement a portal in Svelte

梦想与她 提交于 2020-12-06 12:23:32
问题 In React you can render a component in a different node using Portals: ReactDOM.createPortal( <Component />, document.getElementById('id') ); Same for Vue using the portal-vue package. But is there a way to something similar in Svelte? <body> <Header> <Modal /> <!-- Modal is rendered here --> </Header> <!-- But the Modal DOM would be injected at the body end --> </body> 回答1: See this issue : https://github.com/sveltejs/svelte/issues/3088 Portal.svelte <script> import { onMount, onDestroy }

Implement a portal in Svelte

孤者浪人 提交于 2020-12-06 12:23:21
问题 In React you can render a component in a different node using Portals: ReactDOM.createPortal( <Component />, document.getElementById('id') ); Same for Vue using the portal-vue package. But is there a way to something similar in Svelte? <body> <Header> <Modal /> <!-- Modal is rendered here --> </Header> <!-- But the Modal DOM would be injected at the body end --> </body> 回答1: See this issue : https://github.com/sveltejs/svelte/issues/3088 Portal.svelte <script> import { onMount, onDestroy }