svelte

Vue 3.0 Composition API

我们两清 提交于 2020-04-27 15:01:17
Composition API 发布转载请附原文链接 https://www.cnblogs.com/zgh-blog/articles/composition_api.html 这两天初步了解了下 vue 3.0 相关的一些内容,对于 Composition API 的指导文档过了一遍 (当然根据经验,有些重要的地方可能需要在实践过程中反复思考)。依据自己的理解,对 Composition API 做了一下中文的说明,这里放一下,方便大家在学习的时候能更直接的阅读和理解。如果有误或者有更好的理解,欢迎指出评论~ 一套新增的, 基于函数的 api 让组件逻辑更加灵活。 原因,动机 逻辑复用和代码组织 过去使用 vue 的原因是快速,简单的构建中小型项目。随着 vue 使用者的发展,被用来构建大型项目,这会使团队对项目进行迭代需要耗费更长的时间。过去的时间我们见证了这些项目被 vue 当前的 api 的编程模型所限制,大概有两类问题: 复杂组件在不断扩展中,变得难以理解。特别在我们读别人写的代码时,根本原因是 现有 API 强制按 options 组织代码,没有逻辑关系,实际上,按逻辑关系组织代码更有意义。 缺少一个干净,无成本的机制,在多个组件之间提取和重用逻辑。 新增 API 的目的是提供更灵活的组件组织代码方式。现在不使用 options,而是使用 function 组织代码

How to import Firebase only on client in Sapper?

荒凉一梦 提交于 2020-04-08 04:38:35
问题 I'm importing Firebase into my Sapper application, I do not want the imports to be evaluated on the server. How do I make sure imports are only on the client-side? I am using Sapper to run sapper export which generates the static files. I have tried: Creating the firebase instance in it's own file and exported the firebase.auth() and firebase.firestore() modules. Trying to adjust the rollup.config.js to resolve the dependencies differently, as suggested from the error message below. This

How to import Firebase only on client in Sapper?

血红的双手。 提交于 2020-04-08 04:36:30
问题 I'm importing Firebase into my Sapper application, I do not want the imports to be evaluated on the server. How do I make sure imports are only on the client-side? I am using Sapper to run sapper export which generates the static files. I have tried: Creating the firebase instance in it's own file and exported the firebase.auth() and firebase.firestore() modules. Trying to adjust the rollup.config.js to resolve the dependencies differently, as suggested from the error message below. This

How to import Firebase only on client in Sapper?

泪湿孤枕 提交于 2020-04-08 04:34:31
问题 I'm importing Firebase into my Sapper application, I do not want the imports to be evaluated on the server. How do I make sure imports are only on the client-side? I am using Sapper to run sapper export which generates the static files. I have tried: Creating the firebase instance in it's own file and exported the firebase.auth() and firebase.firestore() modules. Trying to adjust the rollup.config.js to resolve the dependencies differently, as suggested from the error message below. This

Exclude a page from _layout

馋奶兔 提交于 2020-03-23 17:59:29
问题 Hello I am new to Svelte, Sapper & Express. The problem: I am using Sappers _layout.html to display 2 components (header & menu) that should be displayed on all pages, save for the login page. What is the right way to achieve this ? Possible solutions: A) Serve the login page from the static folder, and use the express middleware to route to it? B) Have the login as the root of my project and move all other routes down a level so they can share a common layout that dosnt involve the login

Sapper session not setting properly in production build without page reload

做~自己de王妃 提交于 2020-03-03 09:16:51
问题 I'm working on a project using Sapper, and been struggling with something for a bit now – can't quite figure it out. I'm using Polka for my server (it was included with the sveltejs/sapper-template#rollup template so I went with it), and cookie-session for my session middleware. Here is my Polka configuration, where I seed session data also: polka() .use( compression({ threshold: 0 }), sirv('static', { dev }), cookieSession({ name: 'session', keys: [ '6e818055-d346-4fcb-bf56-4c7d54cb04ab',

Subscribe to a doc using Svelte / RxJs / RxFire. How can I update the subscription

拜拜、爱过 提交于 2020-02-06 06:08:28
问题 I use a derived store in the code below. It feels like a strange construct because I only use the derived construct for the dynamic $session dependency and to get the normData. But not with $norm. I use $norm only once to kick off the derived store. Nevertheless it seem to work fine. But I have to renew the subscription if the $session changes. Is it possible to update the RxFire / RxJs subscription without unsubscribing first? let normDocRef = null; let normData = null; let normSubscription

Subscribe to a doc using Svelte / RxJs / RxFire. How can I update the subscription

吃可爱长大的小学妹 提交于 2020-02-06 06:07:26
问题 I use a derived store in the code below. It feels like a strange construct because I only use the derived construct for the dynamic $session dependency and to get the normData. But not with $norm. I use $norm only once to kick off the derived store. Nevertheless it seem to work fine. But I have to renew the subscription if the $session changes. Is it possible to update the RxFire / RxJs subscription without unsubscribing first? let normDocRef = null; let normData = null; let normSubscription

Sapper event for route change

徘徊边缘 提交于 2020-01-25 06:47:32
问题 I need to redirect users to login page if they are not authenticated. I need something like route.beforeEach in Vue.js, ideally: sapper.beforeRouteChange((to, from, next) => { const isAuth = "[some session or token check]"; if (!isAuth) { next('/login') } next() }) I found Sapper - protected routes (route guard) this question but I think it's not enough for my needs. What if token or auth changes in runtime? OR is it covered by reactivity? Edit 1: I think that this issue on Sapper GitHub

Import css in node_modules to svelte

十年热恋 提交于 2020-01-23 01:25:07
问题 I want to use css framework in my svelte project, in this case it was uikit. I had install it with yarn add uikit And of course i have to import the css file, with @import '../node_modules/uikit/dist/css/uikit.min.css" But that's not work, wherever i'm import that App.svelte style Inside global.css Using tag inside index.html Is this not available yet? Or am I should install that with yarn, and after that I have to copy required file to outside node_modules just like [this solution]?(How to