项目3-加法运算-Vue实现


前端核心代码:

@{
    Layout = null;
}
DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Vue Add Testtitle>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js">script>
    <script src="https://cdn.jsdelivr.net/npm/axios@0.12.0/dist/axios.min.js">script>
    <script src="https://cdn.jsdelivr.net/npm/lodash@4.13.1/lodash.min.js">script>
head>
<body>
    <div id="app">
        <input v-model="a">+<input v-model="b">=<input v-model="c">
        <button v-on:click="cal">本地计算button>
    div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                a: 0,
                b: 0,
                c: 0
            },
            methods: {
                cal: function () {
                    this.c = parseInt(this.a) + parseInt(this.b)
                }
            }
        })
    script>
body>
html>