methods

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue.js函数的定义和使用</title>
    <script src="https://static.gzj2001.com/vue/vue.js"></script>
</head>
<body>
    <div id="myapp">
       <h1>{{site}}-01</h1>
       <!-- 调用函数的时候,小括号要写上 -->
       <h1>{{test()}}</h1>
    </div>
 
    <script>
        let myapp = new Vue({
            el:'#myapp',
            data:{
                site:"城南博客",
                url:"www.gzj2001.com"
            },//不要忘记加,号
            methods:{
                test:function(){
                    return "welcome to :" + this.url;
                }
            }
        })
    </script>
</body>
</html>

通过methods来构造函数。