screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3.2.22/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue Js Count Number of words in Text</h3> <p>Enter a Text:</p> <input v-model="myString" type="text"> <p>Word count: {{ wordCount }}</p> </div> <script type="module"> const app = Vue.createApp({ data() { return { myString: "Vue Js Find Number of Words in Text", }; }, computed: { wordCount() { return this.myString.split(" ").length; }, }, }); app.mount('#app'); </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; margin: 20px; } p { font-size: 18px; margin-bottom: 10px; } input[type="text"] { padding: 10px; border-radius: 5px; border: 1px solid #ccc; font-size: 16px; width: 100%; max-width: 400px; } p:nth-of-type(2) { margin-top: 10px; } </style> </body> </html>