1. We import the ref() function from Vue, which allows us to reference a reactive data source.
  2. We declare a constant variable message which refers to the string \\'Hello World\\'.
  3. Our template uses this constant variable, specifically the value it references, to render to the Document Object Model (DOM).

How can Vue be used to handle user input fields?

Initializing scripts for the Component

  1. The ref() function is imported from Vue.
  2. The ref() function is used to refer to a message.
  3. We define two functions in our scripts, so that we can use them in our templates. Function reverseMessage() can be used to modify the render for our reference message. Function notify() can be used to alert the user if something went wrong.

Creating the template for the Component

  1. The template section will render to the page, and we begin by displaying the referenced message within header tags.
  2. We create one button with a \\'click\\' event listener, which references the reverseMessage() function that we defined in our scripts. Another button is also created, but in this case we use an in-line expression to edit our referenced message.
  3. On our hypertext reference link, we add a specialized \\'click\\' event listener by chaining \\'prevent\\' to the event listener. This is how Vue can be used to prevent defaults!

Optional styling for the Component


How does Vue handle attribute bindings and states?

Initializing scripts for the Component

  1. First, we reference the data message that we will eventually render.

  2. We also reference constant variable isRed to the boolean true. Function toggleRed() is used to toggle this referenced value to either true or false.

  3. We also reference constant variable color to the string \\'green\\'. Function toggleColor() is used with a ternary operator, toggling the reference value to a string of either \\'green\\' or \\'blue\\'.

  4. The references declared in these scripts enables a developer to initialize the state, and then the functions declared therein may also be used to manage/modify the state of the page.


Creating the template for the Component

Now that we have our state initialized, in addition to the tools necessary to modify it, we can begin working on our template. This is where \\'fusion\\' occurs; at this stage we implementing our state references and functions to actually modify what is rendered!

Let\\'s break down what is happening here; each paragraph listed above is denoted with a corresponding number:

  1. In the first paragraph, we target the \\'title\\' property of the current HTML element.

    1. The \\'title\\' property is set equal to that of our referenced message in scripts.
    2. When the output is hovered, our message will display!
  2. In the second paragraph, we are targeting the \\'red\\' class property and we are setting it equal to the current value of isRed.

    1. On a click event the toggleRed() function determines a trueor falseboolean.
    2. The state reference value isRed is assigned to this trueor falseboolean.
    3. When the boolean changes our render will dynamically react to this change; this is because the template is referencing ref() the state of isRedand will change dynamically when this state value is changed.
  3. In the third paragraph, we are targeting the \\'style\\' property and we are setting it equal to the current value of color.

    1. On a click event the toggleColor() function determines a string value.
    2. The state reference value color is reassigned to this string value.
    3. Because our paragraph refers to the value of color, our paragraph styling property is reassigned the value of color.

How does Vue implement conditionals and loops?

Let\\'s take our approach closer to the real-world, so that we can start understanding what the actual workflow would look like when we are working on our own. First, let\\'s start by creating a template of everything we might want to render to the DOM.

Initializing a Component

For now, we have created a few buttons that will be statically rendered to the DOM. We also have created an unordered list, but right now we don\\'t know how long our list will be and we don\\'t even know what we want it to display. At this point, we need to understand what our objectives are.

  1. The button Toggle List will hide our unordered list.
  2. The button Push Number will add an item to our list.
  3. The button Pop Number will remove an item from our list.
  4. The button Reverse List should change the render, causing the list to be displayed in reverse.
  5. Our unordered list needs to reflect a collection of items, and each item needs to be dynamically rendered to the DOM.

I think it is best that we start with displaying each item of our list, so that way we have a way to visualize the DOM before we start implementing scripts that will change what is rendered. In this case, we want our unordered list to have a new list entry for every item in a collection of data.


Adding references and looping through a collection

Great, now we have established a reference to a collection within our scripts! Let\\'s see if we can break down what we did here into something that we can understand.

  1. The constant variable list refers to a collection (array of numbers).
  2. The list entry now has an attribute respective to the v-for directive.######1. The v-for directive receives a collection, and iterates over every item it contains.######2. As the v-for directive is looking at the current item, it creates a new list entry and inserts the specified data there. ######3. In this case we are displaying the entire item in the collection, but that is okay because our collection is only primitive data types and not nested arrays or objects.

Now that we have a way to dynamically render these items, we can review the functionality of our buttons. We will start with the Toggle List button for the time being. In this case, we want the display of our list to switch between two states \\'shown\\' and \\'hidden\\'. Because there are only two states, we can think of this as a true or false expression.


Adding to our Component states

  1. First we declare a constant variable show in our scripts. It refers to a boolean value.
  2. After we add this variable, we can use it for managing the state of content on our page.
  3. We attach a click event listener to the Toggle List button. On click, an expression is evaluated. This inverts the current value of the show variable.

We are close to implementing this functionality, but now we need to account for some edge conditions. What if our list is empty? What if our list is hidden, but it isn\\'t empty? Our current design establishes a way to toggle whether something is rendered to the DOM, but there are no conditional expressions that rely on the state of the show variable. Let\\'s fix that.


Adding conditional expressions to check our states

First, we have added a Vue directive known as v-if to our unordered list. When the DOM attempts to render the list, it first checks the following conditions:

1. If the value of show is true.
2. If the value of list.length is above zero (a truthy value).

If either of these conditions fail, with our current implementation, it would refuse to render the list to the DOM. However, we want to be a bit clearer with our implementation. In this case, we want to expand our conditional expressions so that they will inform the user about the current state of the list.

1. If the list is hidden, but the list is not empty, then we want a message reflecting that.
2. If the list is empty (list.length === 0), then we want a message reflecting that.

Other modifications to states

At this point, we should now have three conditions which are capable of informing the end-user about the state of the list that they are interacting with. This is great progress, but we still need to implement the rest of our buttons. You might notice that, in the previous examples, we are using the properties and methods native to the JavaScript Array prototype. Because we have this functionality, we can interact with our list in the same way.


Final version of our Component

At this point, our DOM should have all of the functionality that we originally set out for it to have! This is what is so powerful about Vue; despite the fact that many similar frameworks and libraries can accomplish this, the approach with Vue feels more natural and developer-friendly.

In the beginning, we starting with a basic and static HTML page. We increased our scale slightly when we made our page somewhat dynamic; we added a reference to list and we also added a directive that helped dynamically render items from that list.

After we added this somewhat dynamic feature, we expanded upon it so that other items could change the state of the DOM. In this case, we increased our scale again as we began handling more states.

If we began increasing our scale further, such as in the case were the list reference pointed to data that is received from the server, then we already have a solid foundation that can be tweaked to reflect data appropriately.


How does Vue interact with other components?

So far, we have only looked at how an individual component can change what is rendered to the DOM. However the reality is that, in most cases, your components should be interacting with one another so that you can reuse them in other parts of the DOM. Let\\'s take a look at an example with a simple component.

Scripts for our Component

We import the ref() function from Vue, but we are also importing the component TodoItem so that we can use it inside of this component. Because subcomponents must be imported and implemented, this creates a separation of concerns.

In separations of concerns, the system\\'s components are organized in a way where each component addresses a single concern; the concern could be simple or it could address a (larger) specific functionality for the DOM. This means that each component only interacts with other components when necessary; this is especially beneficial for ensuring that the overall state of our DOM is not affected when we only want changes to occur within a specific component\\'s scope.

Before we move onto our template for this component, we should understand how the subcomponent that it has imported will work. After all, if we don\\'t know what it is doing then we don\\'t know how to use that component.


The TodoItem Component

It looks like when this component is being setup, it is defining its own properties props to include a key todo that will be assigned to the value of an object. In this case, the properties are looking back to see which data was passed to it as an attribute. Specifically, it is looking for an attribute name todo and it is expecting it to be an Object instance. More documentation on the defineProps() function can be found here.

After the object has been received, the TodoItem component tries to render the text property from the object that has been passed into it. If we have passed the values to it properly, then this should render whatever the value of the text property is for that object. Now we can take a look at how our main App component will try to use the TodoItem component when it renders.


Our template references the TodoItem Component

Inside of our template we are using the Vue directive v-for to iterate through the groceryList collection, which is an array of objects. However, in this case, we are referencing the component TodoItem which we imported earlier. In this case, we are saying the following:

  1. For each item (object) in groceryList (array), pass the item to the TodoItem component.
  2. TodoItem receives two attributes during each iteration:

    1. The todo attribute stores the item (object).
    2. The key attribute is used to create a unique \\'key\\' for each item.
  3. We expect that, for every item in our collection, the TodoItem component will return something to be rendered to the DOM.


Conclusion

I hope that you found this introduction to Vue somewhat helpful, it was a pleasure to research into how this framework can be used to make developers more efficient and effective. If you are familiar with similar frameworks and libraries, you might still be wondering whether or not Vue is something that you would want to use for your own projects. If you feel that way, I recommend that you read through Vue\\'s FAQ to see if its benefits fit the needs of your team, project, or organization.

Is the knowledge of the Vue framework in demand?

According to the 2023 StackOverflow Developer Survey, Vue ranked eighth for one of the most popular web frameworks and technologies at 16.38%. In comparison, similar frameworks and libraries such as React ranked second at 40.58% whereas Angular ranked fifth at 17.46%.

Who uses the Vue framework?

from the Vue website
Vue is one of the most widely used JavaScript frameworks in production today, with over 1.5 million users worldwide. It is downloaded approximately 10 million times a month on Node Package Manager (NPM)!
      - Wikimedia Foundation
      - National Aeronautics and Space Administration (NASA)
      - Apple
      - Google
      - Microsoft
      - GitLab
      - Zoom
      - Tencent
      - Weibo
      - Bilibili
      - Kuaishou
","image":"http://www.luping.net/uploads/20241021/17294778066715bcaee8848.jpg","datePublished":"2024-11-06T13:47:04+08:00","dateModified":"2024-11-06T13:47:04+08:00","author":{"@type":"Person","name":"luping.net","url":"https://www.luping.net/articlelist/0_1.html"}}
”工欲善其事,必先利其器。“—孔子《论语.录灵公》
首页 > 编程 > Vue 框架简介

Vue 框架简介

发布于2024-11-06
浏览:382

Intro to the Vue Framework

What is Vue?

from the Vue website
Vue is a "progressive" JavaScript framework for building user interfaces. It works by building on top of standard HTML, CSS, and JavaScript. It is a component-based programming model similar to that of Anuglar, AngularJS, and React. As a framework, Vue aims to be flexible so that it can adapt to the projects of any scale. It can be implemented for any purpose ranging from creating a static HTML page, embedding web components, and dynamic DOM rendering based on server interactions.

What are the strengths of the Vue framework?

from the Vue website
- Single-File Components (SFC) provide a modularized development model that allows different parts of an application to be developed in isolation.
- Composition API enables clean patterns for organizing, extracting, and reusing complex logic.
- Comprehensive tooling support ensures a smooth development experience as the application grows, which can translate to a more efficient development cycle.
- Lower barrier to entry and excellent documentation translates to lower onboarding/training costs for new developers.

The Basics of the Vue Framework

How can Vue be used to render items to the page?

A simple Component example

  1. We import the ref() function from Vue, which allows us to reference a reactive data source.
  2. We declare a constant variable message which refers to the string 'Hello World'.
  3. Our template uses this constant variable, specifically the value it references, to render to the Document Object Model (DOM).

How can Vue be used to handle user input fields?

Initializing scripts for the Component

  1. The ref() function is imported from Vue.
  2. The ref() function is used to refer to a message.
  3. We define two functions in our scripts, so that we can use them in our templates. Function reverseMessage() can be used to modify the render for our reference message. Function notify() can be used to alert the user if something went wrong.

Creating the template for the Component

  1. The template section will render to the page, and we begin by displaying the referenced message within header tags.
  2. We create one button with a 'click' event listener, which references the reverseMessage() function that we defined in our scripts. Another button is also created, but in this case we use an in-line expression to edit our referenced message.
  3. On our hypertext reference link, we add a specialized 'click' event listener by chaining 'prevent' to the event listener. This is how Vue can be used to prevent defaults!

Optional styling for the Component


How does Vue handle attribute bindings and states?

Initializing scripts for the Component

  1. First, we reference the data message that we will eventually render.

  2. We also reference constant variable isRed to the boolean true. Function toggleRed() is used to toggle this referenced value to either true or false.

  3. We also reference constant variable color to the string 'green'. Function toggleColor() is used with a ternary operator, toggling the reference value to a string of either 'green' or 'blue'.

  4. The references declared in these scripts enables a developer to initialize the state, and then the functions declared therein may also be used to manage/modify the state of the page.


Creating the template for the Component

Now that we have our state initialized, in addition to the tools necessary to modify it, we can begin working on our template. This is where 'fusion' occurs; at this stage we implementing our state references and functions to actually modify what is rendered!

Let's break down what is happening here; each paragraph listed above is denoted with a corresponding number:

  1. In the first paragraph, we target the 'title' property of the current HTML element.

    1. The 'title' property is set equal to that of our referenced message in scripts.
    2. When the output is hovered, our message will display!
  2. In the second paragraph, we are targeting the 'red' class property and we are setting it equal to the current value of isRed.

    1. On a click event the toggleRed() function determines a trueor falseboolean.
    2. The state reference value isRed is assigned to this trueor falseboolean.
    3. When the boolean changes our render will dynamically react to this change; this is because the template is referencing ref() the state of isRedand will change dynamically when this state value is changed.
  3. In the third paragraph, we are targeting the 'style' property and we are setting it equal to the current value of color.

    1. On a click event the toggleColor() function determines a string value.
    2. The state reference value color is reassigned to this string value.
    3. Because our paragraph refers to the value of color, our paragraph styling property is reassigned the value of color.

How does Vue implement conditionals and loops?

Let's take our approach closer to the real-world, so that we can start understanding what the actual workflow would look like when we are working on our own. First, let's start by creating a template of everything we might want to render to the DOM.

Initializing a Component

For now, we have created a few buttons that will be statically rendered to the DOM. We also have created an unordered list, but right now we don't know how long our list will be and we don't even know what we want it to display. At this point, we need to understand what our objectives are.

  1. The button Toggle List will hide our unordered list.
  2. The button Push Number will add an item to our list.
  3. The button Pop Number will remove an item from our list.
  4. The button Reverse List should change the render, causing the list to be displayed in reverse.
  5. Our unordered list needs to reflect a collection of items, and each item needs to be dynamically rendered to the DOM.

I think it is best that we start with displaying each item of our list, so that way we have a way to visualize the DOM before we start implementing scripts that will change what is rendered. In this case, we want our unordered list to have a new list entry for every item in a collection of data.


Adding references and looping through a collection

Great, now we have established a reference to a collection within our scripts! Let's see if we can break down what we did here into something that we can understand.

  1. The constant variable list refers to a collection (array of numbers).
  2. The list entry now has an attribute respective to the v-for directive. ######1. The v-for directive receives a collection, and iterates over every item it contains. ######2. As the v-for directive is looking at the current item, it creates a new list entry and inserts the specified data there. ######3. In this case we are displaying the entire item in the collection, but that is okay because our collection is only primitive data types and not nested arrays or objects.

Now that we have a way to dynamically render these items, we can review the functionality of our buttons. We will start with the Toggle List button for the time being. In this case, we want the display of our list to switch between two states 'shown' and 'hidden'. Because there are only two states, we can think of this as a true or false expression.


Adding to our Component states

  1. First we declare a constant variable show in our scripts. It refers to a boolean value.
  2. After we add this variable, we can use it for managing the state of content on our page.
  3. We attach a click event listener to the Toggle List button. On click, an expression is evaluated. This inverts the current value of the show variable.

We are close to implementing this functionality, but now we need to account for some edge conditions. What if our list is empty? What if our list is hidden, but it isn't empty? Our current design establishes a way to toggle whether something is rendered to the DOM, but there are no conditional expressions that rely on the state of the show variable. Let's fix that.


Adding conditional expressions to check our states

First, we have added a Vue directive known as v-if to our unordered list. When the DOM attempts to render the list, it first checks the following conditions:

1. If the value of show is true.
2. If the value of list.length is above zero (a truthy value).

If either of these conditions fail, with our current implementation, it would refuse to render the list to the DOM. However, we want to be a bit clearer with our implementation. In this case, we want to expand our conditional expressions so that they will inform the user about the current state of the list.

1. If the list is hidden, but the list is not empty, then we want a message reflecting that.
2. If the list is empty (list.length === 0), then we want a message reflecting that.

Other modifications to states

At this point, we should now have three conditions which are capable of informing the end-user about the state of the list that they are interacting with. This is great progress, but we still need to implement the rest of our buttons. You might notice that, in the previous examples, we are using the properties and methods native to the JavaScript Array prototype. Because we have this functionality, we can interact with our list in the same way.


Final version of our Component

At this point, our DOM should have all of the functionality that we originally set out for it to have! This is what is so powerful about Vue; despite the fact that many similar frameworks and libraries can accomplish this, the approach with Vue feels more natural and developer-friendly.

In the beginning, we starting with a basic and static HTML page. We increased our scale slightly when we made our page somewhat dynamic; we added a reference to list and we also added a directive that helped dynamically render items from that list.

After we added this somewhat dynamic feature, we expanded upon it so that other items could change the state of the DOM. In this case, we increased our scale again as we began handling more states.

If we began increasing our scale further, such as in the case were the list reference pointed to data that is received from the server, then we already have a solid foundation that can be tweaked to reflect data appropriately.


How does Vue interact with other components?

So far, we have only looked at how an individual component can change what is rendered to the DOM. However the reality is that, in most cases, your components should be interacting with one another so that you can reuse them in other parts of the DOM. Let's take a look at an example with a simple component.

Scripts for our Component

We import the ref() function from Vue, but we are also importing the component TodoItem so that we can use it inside of this component. Because subcomponents must be imported and implemented, this creates a separation of concerns.

In separations of concerns, the system's components are organized in a way where each component addresses a single concern; the concern could be simple or it could address a (larger) specific functionality for the DOM. This means that each component only interacts with other components when necessary; this is especially beneficial for ensuring that the overall state of our DOM is not affected when we only want changes to occur within a specific component's scope.

Before we move onto our template for this component, we should understand how the subcomponent that it has imported will work. After all, if we don't know what it is doing then we don't know how to use that component.


The TodoItem Component

It looks like when this component is being setup, it is defining its own properties props to include a key todo that will be assigned to the value of an object. In this case, the properties are looking back to see which data was passed to it as an attribute. Specifically, it is looking for an attribute name todo and it is expecting it to be an Object instance. More documentation on the defineProps() function can be found here.

After the object has been received, the TodoItem component tries to render the text property from the object that has been passed into it. If we have passed the values to it properly, then this should render whatever the value of the text property is for that object. Now we can take a look at how our main App component will try to use the TodoItem component when it renders.


Our template references the TodoItem Component

Inside of our template we are using the Vue directive v-for to iterate through the groceryList collection, which is an array of objects. However, in this case, we are referencing the component TodoItem which we imported earlier. In this case, we are saying the following:

  1. For each item (object) in groceryList (array), pass the item to the TodoItem component.
  2. TodoItem receives two attributes during each iteration:

    1. The todo attribute stores the item (object).
    2. The key attribute is used to create a unique 'key' for each item.
  3. We expect that, for every item in our collection, the TodoItem component will return something to be rendered to the DOM.


Conclusion

I hope that you found this introduction to Vue somewhat helpful, it was a pleasure to research into how this framework can be used to make developers more efficient and effective. If you are familiar with similar frameworks and libraries, you might still be wondering whether or not Vue is something that you would want to use for your own projects. If you feel that way, I recommend that you read through Vue's FAQ to see if its benefits fit the needs of your team, project, or organization.

Is the knowledge of the Vue framework in demand?

According to the 2023 StackOverflow Developer Survey, Vue ranked eighth for one of the most popular web frameworks and technologies at 16.38%. In comparison, similar frameworks and libraries such as React ranked second at 40.58% whereas Angular ranked fifth at 17.46%.

Who uses the Vue framework?

from the Vue website
Vue is one of the most widely used JavaScript frameworks in production today, with over 1.5 million users worldwide. It is downloaded approximately 10 million times a month on Node Package Manager (NPM)!
      - Wikimedia Foundation
      - National Aeronautics and Space Administration (NASA)
      - Apple
      - Google
      - Microsoft
      - GitLab
      - Zoom
      - Tencent
      - Weibo
      - Bilibili
      - Kuaishou
版本声明 本文转载于:https://dev.to/sandrockjustin/intro-to-the-vue-framework-3k7i?1如有侵犯,请联系[email protected]删除
最新教程 更多>
  • 如何使用 Java 从 HTML 文档中提取数据?
    如何使用 Java 从 HTML 文档中提取数据?
    Java HTML解析要从网站获取数据,首先必须了解HTML文档的结构。 HTML 元素使用标签进行组织,标签指定每个元素的类型和内容。例如,以下 HTML 表示具有特定 CSS 类的 div 标签:<div class="classname"></div>...
    编程 发布于2024-11-06
  • 为什么 Java 异常处理代码会产生“132Exception in thread main MyExc1”而不是“13Exception in thread main MyExc2”?
    为什么 Java 异常处理代码会产生“132Exception in thread main MyExc1”而不是“13Exception in thread main MyExc2”?
    Java中的异常处理:解开歧义在一个令人费解的Java异常处理场景中,一个大学问题提出了以下代码片段: // Exception Heirarchy class MyExc1 extends Exception {} class MyExc2 extends Exception {} class M...
    编程 发布于2024-11-06
  • 从 shell 脚本迁移到“Bun 脚本”
    从 shell 脚本迁移到“Bun 脚本”
    在 zCloud 从事专注于流程自动化和基础设施的项目时,我们经常遇到需要创建多个函数来执行验证和通用流程的情况。仅使用一种操作系统时一切正常,但当涉及多个系统时情况会变得复杂。 在我们的例子中,大部分开发都发生在 Linux 上,但我们还需要确保与 macOS 的兼容性。这通常会导致代码不兼容。 ...
    编程 发布于2024-11-06
  • 您的 Web 项目中 jQuery 库的最佳来源在哪里?
    您的 Web 项目中 jQuery 库的最佳来源在哪里?
    您应该从哪里获取 jQuery 库?当您的项目中包含 jQuery 和 jQuery UI 时,有多个选项可用。让我们深入研究一下每种方法的优缺点。Google JSAPI 与 CDNGoogle JSAPI 提供了一种从 Google 分布式服务器访问 jQuery 的便捷方法。这可以缩短加载时间...
    编程 发布于2024-11-06
  • PHP 设计模式:适配器
    PHP 设计模式:适配器
    适配器设计模式是一种结构模式,允许具有不兼容接口的对象一起工作。它充当两个对象之间的中介(或适配器),将一个对象的接口转换为另一个对象期望的接口。这允许那些因为具有不同接口而不兼容的类在不修改其原始代码的情况下进行协作。 适配器结构 适配器模式一般由三个主要元素组成: 客户端:期望与特定接口的对象一...
    编程 发布于2024-11-06
  • 了解 PHP 中的 WebSocket
    了解 PHP 中的 WebSocket
    WebSockets 通过单个 TCP 连接提供实时、全双工通信通道。与 HTTP 不同,HTTP 中客户端向服务器发送请求并等待响应,WebSocket 允许客户端和服务器之间进行连续通信,而无需多次请求。这非常适合需要实时更新的应用程序,例如聊天应用程序、实时通知和在线游戏。 在本指南中,我们将...
    编程 发布于2024-11-06
  • Visual Studio 2012 支持哪些 C++11 功能?
    Visual Studio 2012 支持哪些 C++11 功能?
    Visual Studio 2012 中的 C 11 功能随着最近发布的 Visual Studio 2012 预览版,许多开发人员对 C 11 功能的支持感到好奇。虽然 Visual Studio 2010 已提供部分 C 11 支持,但新版本提供了扩展的功能。Visual Studio 2012...
    编程 发布于2024-11-06
  • 如何在Windows启动时自动运行Python脚本?
    如何在Windows启动时自动运行Python脚本?
    在 Windows 启动时运行 Python 脚本每次 Windows 启动时执行 Python 脚本对于自动化任务或启动基本程序至关重要。多种方法提供不同级别的自定义和用户控制。自动执行脚本的选项:1。打包为服务:创建 Windows 服务并安装它。此方法在计算机上运行脚本,无论用户是否登录。需要...
    编程 发布于2024-11-06
  • 探索 Astral.CSS:彻底改变网页设计的 CSS 框架。
    探索 Astral.CSS:彻底改变网页设计的 CSS 框架。
    在快节奏的 Web 开发世界中,框架在帮助开发人员高效创建具有视觉吸引力和功能性的网站方面发挥着关键作用。在当今可用的各种框架中,Astral CSS 因其独特的设计理念和易用性而脱颖而出。本文深入探讨了 Astral CSS 的功能、优点和总体影响。 什么是星界? Astral 是一个现代 CSS...
    编程 发布于2024-11-06
  • ESnd 箭头函数综合指南
    ESnd 箭头函数综合指南
    ES6简介 ECMAScript 2015,也称为 ES6 (ECMAScript 6),是对 JavaScript 的重大更新,引入了新的语法和功能,使编码更高效、更易于管理。 JavaScript 是用于 Web 开发的最流行的编程语言之一,ES6 的改进大大增强了其功能。 本...
    编程 发布于2024-11-06
  • 揭示算法和数据结构:高效编程的基础
    揭示算法和数据结构:高效编程的基础
    在这一系列文章中,我将分享我的学习历程,涉及在学术环境和大型科技公司中广泛讨论的两个主题:算法和数据结构。尽管这些主题乍一看似乎令人畏惧,特别是对于像我这样由于其他职业挑战而在整个职业生涯中没有机会深入研究这些主题的人,但我的目标是让它们易于理解。 我将从最基本的概念开始,然后转向更高级的主题,创建...
    编程 发布于2024-11-06
  • 如何使用 pprof 来分析 Go 程序中的 goroutine 数量?
    如何使用 pprof 来分析 Go 程序中的 goroutine 数量?
    使用 pprof 分析 Goroutine 数量检测 Go 程序中潜在的 Goroutine 泄漏需要监控一段时间内活动的 Goroutine 数量。虽然标准 go 工具 pprof 命令提供了对阻塞的深入了解,但它并不直接解决 goroutine 计数问题。要有效地分析 goroutine 数量,...
    编程 发布于2024-11-06
  • 如何将类方法作为回调传递:了解机制和技术
    如何将类方法作为回调传递:了解机制和技术
    如何将类方法作为回调传递后台在某些场景下,您可能需要将类方法作为回调传递给其他函数以提高效率具体任务的执行。本文将指导您完成实现此目的的各种机制。使用可调用语法要将函数作为回调传递,您可以直接将其名称作为字符串提供。但是,此方法不适用于类方法。传递实例方法类实例方法可以使用数组作为回调传递,该数组以...
    编程 发布于2024-11-06
  • 网页抓取 - 有趣!
    网页抓取 - 有趣!
    一个很酷的术语: CRON = 按指定时间间隔自动安排任务的编程技术 网络什么? 在研究项目等时,我们通常会从各个网站编写信息 - 无论是日记/Excel/文档等。 我们正在抓取网络并手动提取数据。 网络抓取正在自动化这一过程。 例子 当在网上搜索运动鞋时,它会显示包...
    编程 发布于2024-11-06
  • 感言网格部分
    感言网格部分
    ?在学习 CSS 网格时刚刚完成了这个推荐网格部分的构建! ?网格非常适合创建结构化布局。 ?现场演示:https://courageous-chebakia-b55f43.netlify.app/ ? GitHub:https://github.com/khanimran17/Testimonia...
    编程 发布于2024-11-06

免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。

Copyright© 2022 湘ICP备2022001581号-3