如何安装svelte_Svelte入门

2023-10-25 08:10
文章标签 安装 入门 svelte

本文主要是介绍如何安装svelte_Svelte入门,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

如何安装svelte

In this article, we are focussed on understanding the basics of Svelte and getting started with this framework. Svelte is a new uprising client side tool which is definitely worth learning. We will guide you through the basic steps required to setup a Svelte Project and display a simple component.

在本文中,我们着重于了解Svelte的基础知识以及该框架的入门。 Svelte是一种新的起义客户端工具 ,绝对值得学习。 我们将指导您完成设置Svelte项目和显示简单组件所需的基本步骤。

Svelte的用途是什么? (What is Svelte used for?)

演示地址

What is Svelte Used for ?
Svelte用于什么用途?

Svelte is a new framework that can be used to create user interface just like other frameworks like React and Vue. The major update in Svelte does most of the code conversion to lower level at compile time itself. Since the work is done majorly during Compile Time, the svelte application would run and bootstrap faster. Svelte is focussed on

Svelte是一个新框架 ,可以像其他框架如React和Vue一样用于创建用户界面。 Svelte中的主要更新本身在编译时会将大部分代码转换为较低级别。 由于工作主要在编译时完成,因此苗条的应用程序将运行并引导得更快。 Card.svelte专注于

  • Application Performance

    应用性能
  • Reactivity to Changes

    对变化的React
  • Light weighted Library

    轻量图书馆
  • Easy of Code and Use

    易于编码和使用

Svelte比React更好吗? (Is Svelte better than React?)

演示地址

Svelte vs React
Card.sveltevs React

React uses concept of “Virtual DOM”. Every time when there are updates to state variable, Virtual DOMs are compared, react keeps the copy of old DOM tree and DOM construct after the update is made. Once the old and new copy of virtual DOM is available, the changes are propagated to the real DOM. The major hurdle over here is that DOM diffing does not comes for free. Although the algorithms to process the DOM diffing is very efficient, still it is an expensive operation to carry out.

React使用“虚拟DOM”的概念。 每当状态变量有更新时,都会对虚拟DOM进行比较,在更新完成后,react会保留旧DOM树和DOM构造的副本。 一旦可以使用旧的和新的虚拟DOM副本,更改就会传播到真实DOM。 此处的主要障碍是DOM差异并非免费提供。 尽管处理DOM扩散的算法非常有效,但执行起来仍然是昂贵的操作。

Svelte vs React, Svelte vs Vue vs React, Is svelte better than react, Svelte Development

Also in case when we are using Hooks, we cannot put down an expensive operation carelessly in the code. If we put down expensive operation inside a React Component using Hooks, it will be recalculated every time when the component is re-rendered.

同样在使用钩子的情况下,我们不能在代码中粗心地放下昂贵的操作。 如果我们使用Hooks在React组件中放下昂贵的操作,则每次重新渲染组件时都会重新计算该操作。

Also in case of React, we have lot of work that is done in the background, in order to manage the component state. We also end up using complex libraries like “redux”, in order to achieve state management.

同样在React的情况下,为了管理组件状态,我们在后台做了很多工作。 我们最终还会使用复杂的库(例如“ redux”)来实现状态管理。

Svelte is capable of achieving all the functionality of React without the use of Virtual DOM. Svelte compiles the code to tiny frame less vanilla JavaScript to make the application fast and performant.

Svelte能够在不使用虚拟DOM的情况下实现React的所有功能。 Svelte将代码编译为无框架的原始JavaScript,以使应用程序快速高效。

在本地安装和运行Svelte项目 (Installing and Running Svelte Project Locally)

演示地址

Setup Svelte Project Locally
在本地设置Svelte项目

We will guide you through the basic setup steps required in order to get up and running with a Svelte Application…

我们将指导您完成所需的基本设置步骤,以启动并运行Svelte应用程序…

1.获取Svelte示例项目 (1. Getting the Svelte Sample Project)

You need to have Node installed in your local system before we can get the basic Svelte project. Then, we can run the following command in the repository where we are required to create a Svelte Application:

您需要先在本地系统中安装Node,然后才能获取基本的Svelte项目。 然后,我们可以在需要创建Svelte应用程序的存储库中运行以下命令:

npx degit sveltejs/template project-name

npx degit sveltejs / template项目名称

2.转到存储库并安装依赖项 (2. Go to the Repository and Install Dependencies)

Once the repository is created, move to the folder and install the dependencies that are required for the project. The dependencies for the project are specified inside the “package.json” file.

创建存储库后,移至该文件夹并安装项目所需的依赖项。 项目的依赖关系在“ package.json”文件中指定。

cd project-name

cd项目名称

Image for post

The dependencies for the Svelte Project is specified inside “devDependencies” and “dependencies”. We need these dependencies to be available before running the application.

Svelte项目的依赖关系在“ devDependencies”和“ dependencies”中指定。 在运行应用程序之前,我们需要这些依赖项可用。

Run the following commands:

运行以下命令:

npm install

npm安装

3.运行“ dev”脚本 (3. Running the “dev” script)

In “package.json”, we have “scripts” defined, in order to run the development environment, we need to run “dev” script.

在“ package.json”中,我们定义了“脚本”,为了运行开发环境,我们需要运行“ dev”脚本。

npm run dev

npm run dev

This command will execute the Svelte project, and we have the application up and running on port 5000 ( http://localhost:5000/ )

此命令将执行Svelte项目,并且我们已在端口5000( http:// localhost:5000 / )上启动并运行该应用程序

Image for post

Summarizing the setup Steps:

总结设置步骤:

Image for post

In case you are thinking to get started with Svelte follow the Webpage:

如果您想开始使用Svelte,请遵循以下网页:

翻译自: https://medium.com/technofunnel/getting-started-with-svelte-18f42a95056c

如何安装svelte


http://www.taodudu.cc/news/show-8061806.html

相关文章:

  • VSFTP入门
  • 常用的短路保护电器有哪些?
  • 安科瑞电气防火限流式保护器在线路发生短路故障发出报警,减少电气火灾事故的发生
  • centos6搭建redis集群搭建(单机多节点)
  • ubuntu 搭建redis集群三节点
  • MyBatis源码解析初步---一个常用的MyBatis的select执行过程的跟踪
  • 【Docker】Docker镜像讲解
  • docker入门(八):docker镜像加载原理
  • 【Docker】学习笔记01:概述、安装、命令
  • 【Docker】学习笔记02:镜像、容器数据卷
  • Docker学习随笔(一)
  • Docker学习笔记---通俗易懂
  • 当下最火的Docker容器(二)《Java-2021面试谈资系列》
  • 【云原生 | Kubernetes 系列】--Gitops持续交付 CD Push Pipeline实现
  • Redis4.0数据库(三):Redis-sentinel哨兵
  • Apache RocketMQ远程代码执行
  • Redis之——集群搭建(基于CentOS6.X单机多节点)
  • iSpy-最好的开源免费视频监控软件
  • 2023华数杯数学建模C题思路代码 母亲身心健康影响
  • 中等数学2015年增刊模拟题(20)——0
  • 微型计算机 增刊 pdf,《中等数学增刊1-2018》小样.pdf
  • 537. 复数乘法(中等 数学 字符串 模拟)
  • 中等数学-2015-2-利用数论知识解数学竞赛题-例1
  • (3n+1)猜想
  • 7-122 3n+1
  • 3n+1问题(循环)
  • c语言中3n+1问题,C语言每日小练(一)——3n+1问题
  • PAT 1005 继续(3n + 1)猜想
  • matlab解数论问题,Matlab数值积分之数论问题3n+1序列
  • FBL3N/FAGLL03自定义字段显示
  • 这篇关于如何安装svelte_Svelte入门的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



    http://www.chinasem.cn/article/281197

    相关文章

    SQL server数据库如何下载和安装

    《SQLserver数据库如何下载和安装》本文指导如何下载安装SQLServer2022评估版及SSMS工具,涵盖安装配置、连接字符串设置、C#连接数据库方法和安全注意事项,如混合验证、参数化查... 目录第一步:打开官网下载对应文件第二步:程序安装配置第三部:安装工具SQL Server Manageme

    从入门到精通MySQL联合查询

    《从入门到精通MySQL联合查询》:本文主要介绍从入门到精通MySQL联合查询,本文通过实例代码给大家介绍的非常详细,需要的朋友可以参考下... 目录摘要1. 多表联合查询时mysql内部原理2. 内连接3. 外连接4. 自连接5. 子查询6. 合并查询7. 插入查询结果摘要前面我们学习了数据库设计时要满

    Python中win32包的安装及常见用途介绍

    《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作

    从入门到精通C++11 <chrono> 库特性

    《从入门到精通C++11<chrono>库特性》chrono库是C++11中一个非常强大和实用的库,它为时间处理提供了丰富的功能和类型安全的接口,通过本文的介绍,我们了解了chrono库的基本概念... 目录一、引言1.1 为什么需要<chrono>库1.2<chrono>库的基本概念二、时间段(Durat

    解析C++11 static_assert及与Boost库的关联从入门到精通

    《解析C++11static_assert及与Boost库的关联从入门到精通》static_assert是C++中强大的编译时验证工具,它能够在编译阶段拦截不符合预期的类型或值,增强代码的健壮性,通... 目录一、背景知识:传统断言方法的局限性1.1 assert宏1.2 #error指令1.3 第三方解决

    从入门到精通MySQL 数据库索引(实战案例)

    《从入门到精通MySQL数据库索引(实战案例)》索引是数据库的目录,提升查询速度,主要类型包括BTree、Hash、全文、空间索引,需根据场景选择,建议用于高频查询、关联字段、排序等,避免重复率高或... 目录一、索引是什么?能干嘛?核心作用:二、索引的 4 种主要类型(附通俗例子)1. BTree 索引(

    Redis 配置文件使用建议redis.conf 从入门到实战

    《Redis配置文件使用建议redis.conf从入门到实战》Redis配置方式包括配置文件、命令行参数、运行时CONFIG命令,支持动态修改参数及持久化,常用项涉及端口、绑定、内存策略等,版本8... 目录一、Redis.conf 是什么?二、命令行方式传参(适用于测试)三、运行时动态修改配置(不重启服务

    MySQL DQL从入门到精通

    《MySQLDQL从入门到精通》通过DQL,我们可以从数据库中检索出所需的数据,进行各种复杂的数据分析和处理,本文将深入探讨MySQLDQL的各个方面,帮助你全面掌握这一重要技能,感兴趣的朋友跟随小... 目录一、DQL 基础:SELECT 语句入门二、数据过滤:WHERE 子句的使用三、结果排序:ORDE

    gitlab安装及邮箱配置和常用使用方式

    《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

    MySQL MCP 服务器安装配置最佳实践

    《MySQLMCP服务器安装配置最佳实践》本文介绍MySQLMCP服务器的安装配置方法,本文结合实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下... 目录mysql MCP 服务器安装配置指南简介功能特点安装方法数据库配置使用MCP Inspector进行调试开发指