<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                插件通常會為 Vue 添加全局功能。插件的范圍沒有限制——一般有下面幾種: 1. 添加全局方法或者屬性,如: [vue-custom-element](https://github.com/karol-f/vue-custom-element) 2. 添加全局資源:指令/過濾器/過渡等,如 [vue-touch](https://github.com/vuejs/vue-touch) 3. 通過全局 mixin 方法添加一些組件選項,如: [vue-router](https://github.com/vuejs/vue-router) 4. 添加 Vue 實例方法,通過把它們添加到 Vue.prototype 上實現。 5. 一個庫,提供自己的 API,同時提供上面提到的一個或多個功能,如 [vue-router](https://github.com/vuejs/vue-router) ## 使用插件 通過全局方法 `Vue.use()` 使用插件。它需要在你調用 `new Vue()` 啟動應用之前完成: ``` js // 調用 `MyPlugin.install(Vue)` Vue.use(MyPlugin) new Vue({ //... options }) ``` 也可以傳入一個選項對象: ``` js Vue.use(MyPlugin, { someOption: true }) ``` `Vue.use` 會自動阻止多次注冊相同插件,屆時只會注冊一次該插件。 Vue.js 官方提供的一些插件 (例如 `vue-router`) 在檢測到 `Vue` 是可訪問的全局變量時會自動調用 `Vue.use()`。然而在例如 CommonJS 的模塊環境中,你應該始終顯式地調用 `Vue.use()`: ``` js // 用 Browserify 或 webpack 提供的 CommonJS 模塊環境時 var Vue = require('vue') var VueRouter = require('vue-router') // 不要忘了調用此方法 Vue.use(VueRouter) ``` [awesome-vue](https://github.com/vuejs/awesome-vue#components--libraries) 集合了來自社區貢獻的數以千計的插件和庫。 ## 開發插件 Vue.js 的插件應該有一個公開方法 `install`。這個方法的第一個參數是 `Vue` 構造器,第二個參數是一個可選的選項對象: ``` js MyPlugin.install = function (Vue, options) { // 1. 添加全局方法或屬性 Vue.myGlobalMethod = function () { // 邏輯... } // 2. 添加全局資源 Vue.directive('my-directive', { bind (el, binding, vnode, oldVnode) { // 邏輯... } ... }) // 3. 注入組件 Vue.mixin({ created: function () { // 邏輯... } ... }) // 4. 添加實例方法 Vue.prototype.$myMethod = function (methodOptions) { // 邏輯... } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看