I am not able to compile my svelte component when using a get/set pair in custom methods. Is this not supported? Or am I doing something wrong?
Example:
Say I wanted to have a component that displays a name and I want to set the name using.
com.name = 'The new name';
However I only want the component to use the name if it has no spaces in the name.
<h1>Hello {{name}}!</h1>
<script>
export default {
data () {
return {
name: 'The Name',
}
},
methods: {
get displayName() {
return this.get('name');
},
set displayName(val) {
if (val.indexOf(' ') < 0) {
this.set('name', val);
}
}
}
}
</script>
The Issue is that when I try to compile this, it says there is a duplicate key.
Duplicate property 'displayName'
49: return this.get('name');
50: },
51: set displayName(val) {
Here is a REPL - https://svelte.technology/repl?version=1.13.2&gist=0eeab5717526694139ba73eae766bb30
I don't see anything in the documentation about this. I can just not use setters, but I would like to be able to.