Created
May 3, 2019 10:16
-
-
Save jhammann/9afd673572dba31c26de1ae0dacf8ffd to your computer and use it in GitHub Desktop.
A Vue mixin to slugify strings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.mixin({ | |
methods: { | |
slugify(string) { | |
if (typeof string !== 'undefined') { | |
return string.toLowerCase() | |
.replace(/[^\w ]+/g, '') | |
.replace(/ +/g, '_'); | |
} | |
return string; | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment