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
浏览:474

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]删除
最新教程 更多>
  • 为什么使用Firefox后退按钮时JavaScript执行停止?
    为什么使用Firefox后退按钮时JavaScript执行停止?
    导航历史记录问题:JavaScript使用Firefox Back Back 此行为是由浏览器缓存JavaScript资源引起的。要解决此问题并确保在后续页面访问中执行脚本,Firefox用户应设置一个空功能。 警报'); }; alert('inline Alert')...
    编程 发布于2025-07-14
  • Python读取CSV文件UnicodeDecodeError终极解决方法
    Python读取CSV文件UnicodeDecodeError终极解决方法
    在试图使用已内置的CSV模块读取Python中时,CSV文件中的Unicode Decode Decode Decode Decode decode Error读取,您可能会遇到错误的错误:无法解码字节 在位置2-3中:截断\ uxxxxxxxx逃脱当CSV文件包含特殊字符或Unicode的路径逃...
    编程 发布于2025-07-14
  • 为什么Microsoft Visual C ++无法正确实现两台模板的实例?
    为什么Microsoft Visual C ++无法正确实现两台模板的实例?
    在Microsoft Visual C 中,Microsoft consions用户strate strate strate strate strate strate strate strate strate strate strate strate strate strate strate st...
    编程 发布于2025-07-14
  • 如何从Python中的字符串中删除表情符号:固定常见错误的初学者指南?
    如何从Python中的字符串中删除表情符号:固定常见错误的初学者指南?
    从python import codecs import codecs import codecs 导入 text = codecs.decode('这狗\ u0001f602'.encode('utf-8'),'utf-8') 印刷(文字)#带有...
    编程 发布于2025-07-14
  • 如何限制动态大小的父元素中元素的滚动范围?
    如何限制动态大小的父元素中元素的滚动范围?
    在交互式接口中实现垂直滚动元素的CSS高度限制问题:考虑一个布局,其中我们具有与用户垂直滚动一起移动的可滚动地图div,同时与固定的固定sidebar保持一致。但是,地图的滚动无限期扩展,超过了视口的高度,阻止用户访问页面页脚。$("#map").css({ marginT...
    编程 发布于2025-07-14
  • 在PHP中如何高效检测空数组?
    在PHP中如何高效检测空数组?
    在PHP 中检查一个空数组可以通过各种方法在PHP中确定一个空数组。如果需要验证任何数组元素的存在,则PHP的松散键入允许对数组本身进行直接评估:一种更严格的方法涉及使用count()函数: if(count(count($ playerList)=== 0){ //列表为空。 } 对...
    编程 发布于2025-07-14
  • 如何干净地删除匿名JavaScript事件处理程序?
    如何干净地删除匿名JavaScript事件处理程序?
    删除匿名事件侦听器将匿名事件侦听器添加到元素中会提供灵活性和简单性,但是当要删除它们时,可以构成挑战,而无需替换元素本身就可以替换一个问题。 element? element.addeventlistener(event,function(){/在这里工作/},false); 要解决此问题,请考虑...
    编程 发布于2025-07-14
  • 版本5.6.5之前,使用current_timestamp与时间戳列的current_timestamp与时间戳列有什么限制?
    版本5.6.5之前,使用current_timestamp与时间戳列的current_timestamp与时间戳列有什么限制?
    在时间戳列上使用current_timestamp或MySQL版本中的current_timestamp或在5.6.5 此限制源于遗留实现的关注,这些限制需要对当前的_timestamp功能进行特定的实现。 创建表`foo`( `Productid` int(10)unsigned not n...
    编程 发布于2025-07-14
  • 如何从Google API中检索最新的jQuery库?
    如何从Google API中检索最新的jQuery库?
    从Google APIS 问题中提供的jQuery URL是版本1.2.6。对于检索最新版本,以前有一种使用特定版本编号的替代方法,它是使用以下语法:获取最新版本:未压缩)While these legacy URLs still remain in use, it is recommended ...
    编程 发布于2025-07-14
  • Go web应用何时关闭数据库连接?
    Go web应用何时关闭数据库连接?
    在GO Web Applications中管理数据库连接很少,考虑以下简化的web应用程序代码:出现的问题:何时应在DB连接上调用Close()方法?,该特定方案将自动关闭程序时,该程序将在EXITS EXITS EXITS出现时自动关闭。但是,其他考虑因素可能保证手动处理。选项1:隐式关闭终止数...
    编程 发布于2025-07-14
  • 为什么我会收到MySQL错误#1089:错误的前缀密钥?
    为什么我会收到MySQL错误#1089:错误的前缀密钥?
    mySQL错误#1089:错误的前缀键错误descript [#1089-不正确的前缀键在尝试在表中创建一个prefix键时会出现。前缀键旨在索引字符串列的特定前缀长度长度,可以更快地搜索这些前缀。了解prefix keys `这将在整个Movie_ID列上创建标准主键。主密钥对于唯一识别...
    编程 发布于2025-07-14
  • MySQL中如何高效地根据两个条件INSERT或UPDATE行?
    MySQL中如何高效地根据两个条件INSERT或UPDATE行?
    在两个条件下插入或更新或更新 solution:的答案在于mysql的插入中...在重复键更新语法上。如果不存在匹配行或更新现有行,则此功能强大的功能可以通过插入新行来进行有效的数据操作。如果违反了唯一的密钥约束。实现所需的行为,该表必须具有唯一的键定义(在这种情况下为'名称'...
    编程 发布于2025-07-14
  • C++成员函数指针正确传递方法
    C++成员函数指针正确传递方法
    如何将成员函数置于c [&& && && && && && && && && && &&&&&&&&&&&&&&&&&&&&&&&华仪的函数时,在接受成员函数指针的函数时,要在函数上既要提供指针又可以提供指针和指针到函数的函数。需要具有一定签名的功能指针。要通过成员函数,您需要同时提供对象指针(此...
    编程 发布于2025-07-14
  • 用户本地时间格式及时区偏移显示指南
    用户本地时间格式及时区偏移显示指南
    在用户的语言环境格式中显示日期/时间,并使用时间偏移在向最终用户展示日期和时间时,以其localzone and格式显示它们至关重要。这确保了不同地理位置的清晰度和无缝用户体验。以下是使用JavaScript实现此目的的方法。方法:推荐方法是处理客户端的Javascript中的日期/时间格式化和时...
    编程 发布于2025-07-14
  • 大批
    大批
    [2 数组是对象,因此它们在JS中也具有方法。 切片(开始):在新数组中提取部分数组,而无需突变原始数组。 令ARR = ['a','b','c','d','e']; // USECASE:提取直到索引作...
    编程 发布于2025-07-14

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

Copyright© 2022 湘ICP备2022001581号-3