我已阅读文档超过 5 次,但我仍然不明白禁用属性继承的用途是什么,我不明白给出的示例。
我了解 props 的工作原理,它将数据从父组件传递到子组件。
父.vue
<template>
<div id="app">
<Child :num="num"></Child>
</div>
</template>
<script>
import Child from "@/components/Child";
export default {
name: "App",
components: {
Child
},
data() {
return {
num: 42
};
}
};
</script>
Run Code Online (Sandbox Code Playgroud)
儿童.vue
<template>
<div>
<h2>Child</h2>
<h4>num is {{num}}</h4>
<div id="total">
<h4>total is {{total}}</h4>
</div>
</div>
</template>
<script>
export default {
name: "Child",
props: {
num: {
type: Number,
default: 100
}
},
data() {
return {
};
},
computed: {
total() {
return …Run Code Online (Sandbox Code Playgroud) 尝试通过安装 vue js
npm install -g @vue/cli.
Run Code Online (Sandbox Code Playgroud)
我的 npm 版本是 6.14.4,节点版本是 12.16.2
这是我得到的错误
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! Unexpected end of JSON input while parsing near '...nEaUD\r\n=F4TR\r\n---'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Sudesh\AppData\Roaming\npm-cache\_logs\2020-04-16T01_32_53_989Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我尝试查看回购。我不明白这个问题的解决方案是什么。