vue中使用watch为什么报错不让用

一直在watch后面的冒号提示红线,对了别人的都是一样的,就是不知道为什么报错
img

你看看这个冒号是不是中文的

用{}包住函数function试一下呢

鼠标放在红线上也可以看看提示是什么

<title>Document</title>

<style>
    #app {
        width: 500px;
        margin: auto;
        text-align: center;
    }
    
    #app table {
        width: 100%;
        border-collapse: collapse;
    }
    
    #app th,
    td {
        padding: 10px;
        height: 35px;
        line-height: 35px;
        border: 1px solid red;
    }
    
    #app th {
        background-color: orange;
    }
    
    #app thead:first-child {
        height: 20px;
    }
    
    #app thead.book tr {
        height: 20px;
    }
    
    .book {
        height: 30px;
        background-color: orange;
        border: 1px solid red;
    }
</style>

图书管理

编号: 名称: 提交
编号名称时间操作
{{item.id}}{{item.name}}{{item.date}}删除 https://ask.csdn.net/questions/7486737?spm=1001.2014.3001.5501 | 修改 https://ask.csdn.net/questions/7486737?spm=1001.2014.3001.5501

看看报错信息,应该是watch位置放错了

new Vue({
  el: '#root',
  data: {
    cityName: 'shanghai'
  },
  watch: {
    cityName(newName, oldName) {
      // ...
    }
  } 
})

就是watch位置错了,格式不对

watch位置不对