Migrate from vue 1.x to vue 2.x

You have written the code given below in vue 1.x.

props: {
 name: {
    type: String,
    coerce: function (value) {
      return value
        .toLowerCase()
        .replace(/\s+/, '-')
    }
  }
}
If you port the same code to vue 2.x, what would be the equivalent code?
Options
1.props: {
  name: String ::coerce: {
  name: function () {
    return this.name|.toLowerCase()
      .replace(/\s+/, '-');
  }
}
2.props: {
  name: String=>coerce: {
  normalize().name: function (){
    return this.username
      .toLowerCase()
      .replace(\s+/, '-')
  }
}

3.props: {
  name: String,
},
computed: {
  normalized name: function () {
    return this.name
      .toLowerCase()
      .replace(/\s+/, '-')
  }
}

4.props: {
  name: String,
},
computed: {
      return this.name
      .toLowerCase()
      .replace(\.()s+/, '-')
  }
}

Related Posts