本指南適用於當您想要確保 Quasar 插件 將被注入到宿主應用程式時,因為您的應用程式擴展功能需要依賴它才能運作。
提示
為了建立應用程式擴展專案資料夾,請先閱讀開發指南 > 簡介。
完整範例
若要查看我們將建構的範例,請前往完整範例,這是一個包含此應用程式擴展功能的 GitHub 儲存庫。
我們只需要 /index.js 腳本,因為我們可以使用Index API 從宿主應用程式設定 quasar.config 檔案,以包含我們需要的 Quasar 插件。
./
package.json
src/
index.js
# 在 Index API 中描述
而 /index.js 看起來會像這樣
export default function (api) {
// (Optional!)
// Quasar compatibility check; you may need
// hard dependencies, as in a minimum version of the "quasar"
// package or a minimum version of Quasar App CLI
api.compatibleWith('quasar', '^2.0.0')
if (api.hasVite === true) {
api.compatibleWith('@quasar/app-vite', '^2.0.0-beta.1')
}
else { // api.hasWebpack === true
api.compatibleWith('@quasar/app-webpack', '^4.0.0-beta.1')
}
// Here we extend /quasar.config file, so we can add
// a boot file which registers our new Vue directive;
// "extendConf" will be defined below (keep reading the tutorial)
api.extendQuasarConf(extendConf)
}
content_paste
我們的 “extendConf” 方法,與上述檔案相同
function extendConf (conf) {
// we push to /quasar.config file > framework > plugins:
conf.framework.plugins.push('AppVisibility')
}
content_paste