Vue--全局API

Vue.extend( options )

  • 参数vue

    • {Object} options
  • 用法api

    使用基础 Vue 构造器,建立一个“子类”。参数是一个包含组件选项的对象。函数

<div id="mount-point"></div>
// 建立构造器
var Profile = Vue.extend({
  template: '<p>{{firstName}} {{lastName}} aka {{alias}}</p>',
  data: function () {
    return {
      firstName: 'Walter',
      lastName: 'White',
      alias: 'Heisenberg'
    }
  }
})
// 建立 Profile 实例,并挂载到一个元素上。
new Profile().$mount('#mount-point')

 

Vue.nextTick( [callback, context] )

  • 参数url

    • {Function} [callback]
    • {Object} [context]
  • 用法spa

    在下次 DOM 更新循环结束以后执行延迟回调。在修改数据以后当即使用这个方法,获取更新后的 DOM。.net

Vue.set( target, key, value )

  • 参数插件

    • {Object | Array} target
    • {string | number} key
    • {any} value
  • 返回值:设置的值。code

  • 用法component

    设置对象的属性。若是对象是响应式的,确保属性被建立后也是响应式的,同时触发视图更新。这个方法主要用于避开 Vue 不能检测属性被添加的限制。对象

Vue.delete( target, key )

  • 参数

    • {Object | Array} target
    • {string | number} key/index

    仅在 2.2.0+ 版本中支持 Array + index 用法。

  • 用法

    删除对象的属性。若是对象是响应式的,确保删除能触发更新视图。这个方法主要用于避开 Vue 不能检测到属性被删除的限制,可是你应该不多会使用它。

Vue.directive( id, [definition] )

  • 参数

    • {string} id
    • {Function | Object} [definition]
  • 用法

    注册或获取全局指令。

Vue.component( id, [definition] )

  • 参数

    • {string} id
    • {Function | Object} [definition]
  • 用法

    注册或获取全局组件。注册还会自动使用给定的id设置组件的名称

Vue.use( plugin )

  • 参数

    • {Object | Function} plugin
  • 用法

    安装 Vue.js 插件。若是插件是一个对象,必须提供 install 方法。若是插件是一个函数,它会被做为 install 方法。install 方法将被做为 Vue 的参数调用。

    当 install 方法被同一个插件屡次调用,插件将只会被安装一次。

Vue.mixin( mixin )

  • 参数

    • {Object} mixin
  • 用法

    全局注册一个混合,影响注册以后全部建立的每一个 Vue 实例。插件做者能够使用混合,向组件注入自定义的行为。不推荐在应用代码中使用

Vue.compile( template )

  • 参数

    • {string} template
  • 用法

    在 render 函数中编译模板字符串。只在独立构建时有效

Vue.version

  • 细节:提供字符串形式的 Vue 安装版本号。这对社区的插件和组件来讲很是有用,你能够根据不一样的版本号采起不一样的策略。

相关文章
相关标签/搜索