[{"data":1,"prerenderedAt":213},["ShallowReactive",2],{"blog-en-\u002Fblog\u002Fv-model-gerador-assinaturas-vue":3},{"id":4,"title":5,"body":6,"date":200,"description":201,"extension":202,"meta":203,"navigation":204,"path":205,"seo":206,"stem":207,"tags":208,"__hash__":212},"blog_en\u002Fblog\u002Fv-model-gerador-assinaturas-vue.md","Vue.js 2 and v-model in an email signature generator",{"type":7,"value":8,"toc":198},"minimark",[9,13,16,19,27,30,65,68,84,87,191,194],[10,11,12],"p",{},"Today I was studying how to use Vue.js 2 to create a dynamic screen in an email signature generator.",[10,14,15],{},"I needed to create a simple way for the user to fill in some data, like name, role, phone and email, and see the signature being assembled automatically on the screen.",[10,17,18],{},"At first I thought about doing everything with plain HTML, CSS and JavaScript, handling the fields manually. But I started to realize that, as the screen gained more fields and rules, that could become hard to maintain.",[10,20,21,22,26],{},"I found it interesting how Vue.js 2 made it easier to bind the form inputs to the signature preview. With ",[23,24,25],"code",{},"v-model",", I could update the data in real time without having to write several functions to manipulate the DOM manually.",[10,28,29],{},"In the form, I could have a field for the name:",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-html shiki shiki-themes darcula","\u003Cinput v-model=\"name\" placeholder=\"Digite seu nome\">\n","html","",[23,38,39],{"__ignoreMap":36},[40,41,44,48,52,56,59,62],"span",{"class":42,"line":43},"line",1,[40,45,47],{"class":46},"s2lgc","\u003Cinput",[40,49,51],{"class":50},"sE2CK"," v-model=",[40,53,55],{"class":54},"sZ3PO","\"name\"",[40,57,58],{"class":50}," placeholder=",[40,60,61],{"class":54},"\"Digite seu nome\"",[40,63,64],{"class":46},">\n",[10,66,67],{},"And in the signature preview, that value could already show up automatically:",[31,69,71],{"className":33,"code":70,"language":35,"meta":36,"style":36},"\u003Cstrong>{{ name }}\u003C\u002Fstrong>\n",[23,72,73],{"__ignoreMap":36},[40,74,75,78,81],{"class":42,"line":43},[40,76,77],{"class":46},"\u003Cstrong>",[40,79,80],{"class":50},"{{ name }}",[40,82,83],{"class":46},"\u003C\u002Fstrong>\n",[10,85,86],{},"In the JavaScript, the data would be centralized in the Vue instance:",[31,88,92],{"className":89,"code":90,"language":91,"meta":36,"style":36},"language-js shiki shiki-themes darcula","new Vue({\n  el: '#app',\n  data: {\n    name: '',\n    role: '',\n    email: '',\n    phone: ''\n  }\n})\n","js",[23,93,94,106,122,131,144,156,168,179,185],{"__ignoreMap":36},[40,95,96,100,103],{"class":42,"line":43},[40,97,99],{"class":98},"sYMgc","new",[40,101,102],{"class":46}," Vue",[40,104,105],{"class":50},"({\n",[40,107,109,113,116,119],{"class":42,"line":108},2,[40,110,112],{"class":111},"sk7qV","  el",[40,114,115],{"class":50},": ",[40,117,118],{"class":54},"'#app'",[40,120,121],{"class":50},",\n",[40,123,125,128],{"class":42,"line":124},3,[40,126,127],{"class":111},"  data",[40,129,130],{"class":50},": {\n",[40,132,134,137,139,142],{"class":42,"line":133},4,[40,135,136],{"class":111},"    name",[40,138,115],{"class":50},[40,140,141],{"class":54},"''",[40,143,121],{"class":50},[40,145,147,150,152,154],{"class":42,"line":146},5,[40,148,149],{"class":111},"    role",[40,151,115],{"class":50},[40,153,141],{"class":54},[40,155,121],{"class":50},[40,157,159,162,164,166],{"class":42,"line":158},6,[40,160,161],{"class":111},"    email",[40,163,115],{"class":50},[40,165,141],{"class":54},[40,167,121],{"class":50},[40,169,171,174,176],{"class":42,"line":170},7,[40,172,173],{"class":111},"    phone",[40,175,115],{"class":50},[40,177,178],{"class":54},"''\n",[40,180,182],{"class":42,"line":181},8,[40,183,184],{"class":50},"  }\n",[40,186,188],{"class":42,"line":187},9,[40,189,190],{"class":50},"})\n",[10,192,193],{},"My initial impression is that Vue.js 2 helped a lot with small but dynamic screens. For an email signature generator it made sense, because I could create a more interactive experience, where the person filled in the data and already saw the final result being updated in real time.",[195,196,197],"style",{},"html pre.shiki code .s2lgc, html code.shiki .s2lgc{--shiki-default:#FFC66D}html pre.shiki code .sE2CK, html code.shiki .sE2CK{--shiki-default:#A9B7C6}html pre.shiki code .sZ3PO, html code.shiki .sZ3PO{--shiki-default:#6A8759}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sYMgc, html code.shiki .sYMgc{--shiki-default:#CC7832}html pre.shiki code .sk7qV, html code.shiki .sk7qV{--shiki-default:#9876AA}",{"title":36,"searchDepth":108,"depth":108,"links":199},[],"2021-12-03","Study notes on using Vue.js 2 to create a dynamic screen in an email signature generator, with v-model binding the form to the signature preview.","md",{},true,"\u002Fblog\u002Fv-model-gerador-assinaturas-vue",{"title":5,"description":201},"blog\u002Fv-model-gerador-assinaturas-vue",[209,210,211],"vue","javascript","fundamentals","IZFjjG5RaPX9NIguSaxEvyNz-98unOxCip67TsEwS0k",1794928450318]