vue.js

93 阅读2分钟
v-model :model v-bind 的区别

  1. v-model:

v-model 是 v-model:value 的缩写,通常用于表单上的双向数据绑定(表单接受值 value,故v-model默认收集的就是 value ,所以缩写直接省略 value),可以实现子组件到父组件的双向数据动态绑定。数据不仅能从data流向页面,还可以从页面流向data。

  1. :model:

:model 是 v-bind:model 的缩写,可以实现将父组件的值传递给子组件,但是子组件不能传给父组件,无法双向绑定。

  1. v-bind:

v-bind:value 可以简写为 :value ,数据只能从data流向页面。

  1. # vue的await用法是什么:

先说一下async的用法,它作为一个关键字放到函数前面,用于表示函数是一个异步函数,因为async就是异步的意思, 异步函数也就意味着该函数的执行不会阻塞后面代码的执行。 写一个async 函数

async function timeout() {
  return 'hello world';
}

await是等待的意思,那么它等待什么呢,它后面跟着什么呢?其实它后面可以放任何表达式,不过我们更多的是放一个返回promise 对象的表达式。注意await 关键字只能放到async 函数里面

handleDelete(row) { // 执行后端 删除方法
  this.$confirm('你确定要删除该信息, 是否继续?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(async() => {
    await deleteDictDetail(row.id)
    this.getData()
    this.$message({ type: 'success', message: '删除成功!' })
  }).catch(() => {
    this.$message({ type: 'success', message: '已取消删除' })
  })
}

  1. # vue的import用法是引入:

import { deleteDictDetail , actionIndex } from '@/api/marketing'  
  1. # Element组件实现Pagination 分页:

import Pagination from '@/components/Pagination'
  1. # Element ConfirmButton组件:

ConfirmButton是一个捕获按钮点击事件的扩展控件(或者按钮类型的事件,例如:LinkButton,ImageButton等)。在按钮的事件被执行前先确认是否要继续,它会弹出一个确认对话框。 cancelButtonText 为取消 type: 'warning'