svelte

Bind <svelte:window> to `onbeforeunload`

自古美人都是妖i 提交于 2021-02-07 10:20:06
问题 I was hoping to bind to <svelte:window> but have no luck. <!-- doesn't work --> <svelte:window on:beforeunload={() => true} /> <!-- doesn't work --> <svelte:window on:onbeforeunload={() => true} /> <!-- doesn't work --> <svelte:window on:beforeUnload={() => true} /> in all instances, window.onbeforeunload is null I ended up just going with window.onbeforeunload = () => true but was wondering why setting on the element didn't work. 回答1: You need to set the event returnValue when using svelte

How to integrate Material UI into Svelte project

佐手、 提交于 2021-02-07 08:13:54
问题 I want to integrate Material UI into my Svelte project. I tried to follow the official documentation from here, but I don't know why I'm getting a strange error while trying to run my project: loaded rollup.config.js with warnings (!) Unused external imports default imported from external module 'rollup-plugin-postcss' but never used rollup v1.27.13 bundles src/main.js → public/build/bundle.js... [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

How to integrate Material UI into Svelte project

北城余情 提交于 2021-02-07 08:10:23
问题 I want to integrate Material UI into my Svelte project. I tried to follow the official documentation from here, but I don't know why I'm getting a strange error while trying to run my project: loaded rollup.config.js with warnings (!) Unused external imports default imported from external module 'rollup-plugin-postcss' but never used rollup v1.27.13 bundles src/main.js → public/build/bundle.js... [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

How can i navigate to different path on click in svelte?

为君一笑 提交于 2021-01-29 16:37:57
问题 Currently in having on:click | preventDefault="{() => showDetail({id})}" and in showDetail function i want to naviagte to particular id which in i am passing on click of button. I tried regular javascript method location.assign but this is reloading the page and destroying the purpose of SPA. Is there any way to navigate in svelte without reloading 回答1: You need a router. There are SPA routers (Single Page Application) and SSR router (Server Side Rendering). You may try : https://routify.dev/

Disable hydration in Sapper

六月ゝ 毕业季﹏ 提交于 2021-01-29 10:15:29
问题 I was testing Sapper and got stuck with complex TweenMax page transitions I'm used to do when working with BarbaJS or HighwayJS, so I'm wondering is there's a way to disable hydration in Sapper so that I can only have the SSR website I can bend to my will. If there's a way, that would be great. 回答1: Sure — just delete the code in src/client.js that starts the app 来源: https://stackoverflow.com/questions/58641735/disable-hydration-in-sapper

Dependecies of node_module inside another node_module

荒凉一梦 提交于 2021-01-29 09:37:06
问题 I have to create a new node_module, inside this i need to use other modules, in this case uuid and object-exporter. When i run my module i have this error inside the bundle /.../node_modules/Table/dist/bundle.js:1981 }({}, uuid)); ^ ReferenceError: uuid is not defined I imported the lib on package.json on depencencies "dependencies": { "object-exporter": "^3.6.0", "uuid": "^8.3.1" }, Anyone has some advice? I have to import the node_module on a sapper template 来源: https://stackoverflow.com

What is the best way to signal 50+ nested components to execute a child component function in svelte 3

天涯浪子 提交于 2021-01-29 03:08:18
问题 Example In a table with rows (child components). I need To do a text search in every row and mark the rows with results. I'am starting with svelte and it looks very very interesting. How to signal all svelte child components (rows) to execute the row search. I can toggle a store, but there must be a fundemental better way? Child.svelte: <script> export let child; // child id import {signal} from './store.js'; let fired = false $: if ($signal) { fired = true; setTimeout(() => fired = false,

Cypress submitting form with preventDefault

左心房为你撑大大i 提交于 2021-01-28 08:53:08
问题 I am having trouble using Cypress. There are 2 problems I'm currently having. A form with preventDefault is being submitted and the page is refreshing. I have to .click() and input before I can .type() into it. -- I have a form that has preventDefault, and you can see from the test that it submites the form, which adds a empty query string to the url, and none of my error handling messages are shown. This doesn't actually happen when I use the app myself. it('requires email', () => { cy.visit

How to persist UI component state data in Sapper?

主宰稳场 提交于 2021-01-28 06:00:49
问题 In a Sapper app, I want to be able to persist the state of some UI components so I can navigate the app without losing state when the user returns to the pages using those components. In a Svelte-only app, this is usually done with a custom store that uses the sessionStorage or localStorage API. A good example of that can be found in R. Mark Volkmann's book Svelte and Sapper in Action , §6.24: store-util.js import {writable} from 'svelte/store'; function persist(key, value) { sessionStorage

Using leaflet-d3 on svelte

杀马特。学长 韩版系。学妹 提交于 2021-01-27 18:57:45
问题 i have to use leaflet-d3 on svelte to create a hexmap. I'm using a code already tested for other stuff. It can be found here. function createMap(id, config, zoomFunction) { let initialView = [config.startLat, config.startLng]; if(!config.startLat || !config.startLng){ initialView = [0,0] config.startZoom = 1; } let m = L.map(id, {preferCanvas: true, minZoom: config.minZoom, maxZoom: config.maxZoom }).setView(initialView, config.startZoom); let layers = { 'Street map': L.tileLayer.provider(