[英]“npm install” not installing any library. How to resolve this issue?
[英]vue 3. how to build NPM library. ref() dont work in npm package
你好,我為我的代碼制作了一個簡單的 vue 3 庫。
export class REfTest() {
private ref = ref(null)
constructor(value: any) { this.ref.value = value }
update(value) {
this.ref.value = value;
}
}
我使用 npm 鏈接從庫中創建了 class 的實例。 但沒有任何效果。 由於某種原因,反應停止了工作。 此外,包含所有庫代碼的文件重 160 KB。 很多。 據我了解,他編譯並將vue3添加到該文件中,這就是為什么它不起作用並且文件如此之大的原因。 這是依賴文件
{
"name": "ref-tets",
"version": "1.0.0",
"description": "",
"main": "./dist/index.js",
"scripts": {
"build": "webpack"
},
"keywords": [],
"license": "ISC",
"devDependencies": {
"ts-loader": "^9.3.1",
"typescript": "^4.7.4",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0"
},
"peerDependencies": {
"vue": "^3.0.0"
},
"files": [
"dist"
]
}
我指出 vue3 是對等依賴項。 但沒有幫助
你忘記從 vue 導入 ref。
請將下面的行添加到代碼片段的頂部。
import { ref } from "vue"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.