svelte

Can I set svelte style css attribute values using variables passed in to a component

生来就可爱ヽ(ⅴ<●) 提交于 2020-06-26 04:47:52
问题 I want to create a svelte component that receives the name and path of an image. I want to have the component set the image as the "background-image" using CSS. I've tried the following which does not seem to work... Component called in App.svelte : <Image image_url='./images/image1.jpg' /> Image.Svelte <script> export let image_url; </script> <style> .image{ position:relative; opacity: 0.70; background-position:bottom; background-size: cover; background-repeat: no-repeat; background

How to bind variable declared with Svelte let directive?

自闭症网瘾萝莉.ら 提交于 2020-06-25 04:21:06
问题 I'm trying to workaround "Cannot bind to a variable declared with the let: directive" error. // FancyList.svelte <script> export let items = [] </script> <ul> {#each items as item, i} <li><slot item={item}></slot></li> {/each} </ul> // App.svelte <script> import FancyList from './FancyList.svelte' let items = [ {x: 'AX', y: 'AY'}, {x: 'BX', y: 'BY'}, {x: 'CX', y: 'CY'}] </script> <FancyList bind:items={items} let:item={item}> <input type=text bind:value={item.x}> <input type=text bind:value=

Svelte 3, async onMount or a valid alternative?

安稳与你 提交于 2020-06-14 15:33:54
问题 What I need is to use async-await in Svelte onMount() . Or maybe you can suggest me what is wrong and what I can use alternatively. To Reproduce go here: https://svelte.dev/repl/000ae69c0fe14d9483678d4ace874726?version=3.23.0 open the console click on the button you should see messages: "Mounting..." and "A lot of background work..." if you click again the destroy message is not written WHY? Did onMount() recognizes the async function promise? Should it? I need that async behavior because I

Svelte 3, async onMount or a valid alternative?

ε祈祈猫儿з 提交于 2020-06-14 15:30:51
问题 What I need is to use async-await in Svelte onMount() . Or maybe you can suggest me what is wrong and what I can use alternatively. To Reproduce go here: https://svelte.dev/repl/000ae69c0fe14d9483678d4ace874726?version=3.23.0 open the console click on the button you should see messages: "Mounting..." and "A lot of background work..." if you click again the destroy message is not written WHY? Did onMount() recognizes the async function promise? Should it? I need that async behavior because I

How to put a Svelte app in a docker container?

蹲街弑〆低调 提交于 2020-06-14 15:03:28
问题 The title pretty much says it all. I am very new to web development. I created a Svelte app using npx degit sveltejs/template ... . Now I run it locally using npm run dev or npm start . To my understanding, this is a Node server, but adapting their official tutorial didn't get me very far. Thanks. I found a blog post about this, but it doesn't quite explain how to dockerize an existing Svelte app, instead points to a fork of the official template. 回答1: You can place a Dockerfile in your app

How to put a Svelte app in a docker container?

折月煮酒 提交于 2020-06-14 15:01:54
问题 The title pretty much says it all. I am very new to web development. I created a Svelte app using npx degit sveltejs/template ... . Now I run it locally using npm run dev or npm start . To my understanding, this is a Node server, but adapting their official tutorial didn't get me very far. Thanks. I found a blog post about this, but it doesn't quite explain how to dockerize an existing Svelte app, instead points to a fork of the official template. 回答1: You can place a Dockerfile in your app

How to put a Svelte app in a docker container?

自闭症网瘾萝莉.ら 提交于 2020-06-14 15:00:29
问题 The title pretty much says it all. I am very new to web development. I created a Svelte app using npx degit sveltejs/template ... . Now I run it locally using npm run dev or npm start . To my understanding, this is a Node server, but adapting their official tutorial didn't get me very far. Thanks. I found a blog post about this, but it doesn't quite explain how to dockerize an existing Svelte app, instead points to a fork of the official template. 回答1: You can place a Dockerfile in your app

Svelte/Sapper.js - How to initialize store with localStorage data?

北城以北 提交于 2020-06-09 12:13:26
问题 I come from a React background but I'm switching to Svelte and Sapper for my next application in order to fight the massive bundle size that comes with React these days. However, I'm having trouble initializing Svelte's store with data retreived from localStorage. As per the Sapper docs (https://sapper.svelte.dev/docs#Getting_started), I created my project by running npx degit "sveltejs/sapper-template#rollup" my-app from the command line. I then installed the dependencies and removed the

Svelte Mount DOM Element from Javascript

泄露秘密 提交于 2020-05-30 03:35:30
问题 I'm trying to mount a pixi.js canvas with Svelte like below. app.view is an HTML Canvas element but I'm not sure how to display it with Svelte. <script> import * as PIXI from 'pixi.js' import { onMount } from 'svelte'; let app = new PIXI.Application({ width: 256, // default: 800 height: 256, // default: 600 antialias: true, // default: false transparent: false, // default: false resolution: 1 // default: 1 }) </script> <style></style> <app.view /> I'm just using this for the time being but it

sapper as static site generator

冷暖自知 提交于 2020-04-30 06:25:30
问题 I would like to use sapper as ssg. When I get data like so: <script context="module"> export function preload({ params, query }) { return this.fetch(`https://jsonplaceholder.typicode.com/posts`) .then(r => r.json()) .then(posts => { return {posts} }) } I can export the site to static. But on links the data still gets fetched from jsonplaceholder. Only on reload the data gets from the static folder. How to get all fetched data static? 回答1: So this can be a bit confusing in the beginning. To