Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

1.props验证总是报错
2.相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
</head>
<body>
<div id="app">
    <example :propC="100"></example>
</div>
</body>
<script type="text/javascript">

    Vue.component('example', {
        props: {
            propC: {
                type: String,
                required: true
            },
            propD: {
                type: Number,
                default: 100
            }
        },
        template: '<h1>{{propC}}-{{propD}}</h1>'
    })

    var vm = new Vue({
        el: '#app',
        data: {
            msg: 'hello world',
            num: 100
        }
    })


</script>
</html>
  1. 运行结果:
    图片描述


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
317 views
Welcome To Ask or Share your Answers For Others

1 Answer

html标签属性不识别大小写 你 propC 要写成 prop-c


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...