首页 > 其他分享 >vue-2 模板语法

vue-2 模板语法

时间:2022-10-08 17:22:42浏览次数:63  
标签:vue smarty 语法 Vue import router 模板

router/index.js
//1、引入基础依赖 import Vue from 'vue' import Router from 'vue-router' //2、引入要路由的页面 import Smarty from "../components/smarty" //3、将Router插件注册为Vue全局组件 Vue.use(Router) const router = new Router({ routes:[ { path: '/smarty', name: 'smarty', component: Smarty } ] }) export default router
APP.vue
import Vue from 'vue' import App from './App.vue' import router from './router' Vue.config.productionTip = false new Vue({ render: h => h(App), router //添加路由 }).$mount('#app')

 


<template> <div id="app"> <div> <router-link to="smarty">模板语法</router-link> </div> <div>-------------------------------------</div> <router-view></router-view> </div> </template> <script> export default { name: 'App', } </script> <style> #app { font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; } </style>
smarty.vue

<template> <div> <h1>模板语法</h1> <h2>插值语法{{title}}</h2> <div>html:{{html}}</div> "v-html:"<span v-html="html"></span><br /> <input type="button" v-bind:value="buttonTitle" /> 缩写:<input type="button" :value="buttonTitle" /> <div>计算:{{ num +1 }}</div> <a :href="url">百度</a><br/> <input type="button" value="确认" @click="onsubmit" /> </div> </template> <script> export default { name: 'smarty', data() { return { title: "Vue模板语法标题", html: "hello,<span style='color: red'>张三</span>。", buttonTitle: "确认", num: 10, url: "https://www.baidu.com" } }, methods: { onsubmit(){ alert("确认") } } } </script>

 

标签:vue,smarty,语法,Vue,import,router,模板
From: https://www.cnblogs.com/dwdw/p/16769590.html

相关文章

  • vue的computed计算属性的执行机制
    vue中初始化computed,每一个计算属性的本质就是watcher,创建计算属性的watcher的时候,会传入一个懒惰属性,来控制computed缓存,默认是执行的,先处理为vm._computedWatchers对象......
  • vuecli build 代码拆解
    splitChunks:{//表示选择哪些chunks进行分割,可选值有:async,initial和allchunks:"async",//表示新分离出的chunk必须大于等于minSize,默认为30000,约3......
  • vuex中commit
    一、不使用模块的基础模式看vuex相关的文件夹,放在src下的store文件夹,里面有一个index.js文件,为vuex的入口,如果不使用模块,可以将所有相关代码写在index.js文件里面,下面是最......
  • Luogu P3389【模板】高斯消元法
    题意给定一个线性方程组,对其求解。$1\leqn\leq100,\left|a_i\right|\leq{10}^4,\left|b\right|\leq{10}^4$题解因为之前贺题解的时候没有理解高斯-约......
  • Python基础语法:函数
    1函数定义 1.1函数概述在程序设计中,函数的使用可以提升代码的复用率和可维护性。提升代码的复用率:程序设计中,一些代码的功能是相同的,操作是一样的,只不过针对的数据......
  • Markdown语法
    标题几个‘#’加空格就是寄级标题字体用两个*括起来是加粗用一个括起来是斜体*用三个括起来是加粗斜体*用两个波浪号括起来是划线引用一个大于符号加空格分割线......
  • vue.js3:axios图片上传([email protected] / [email protected])
    一,安装axios库1,相关地址官网:https://axios-http.com/代码地址:https://github.com/axios/axios2,安装liuhongdi@lhdpc:/data/vue/axios$npminstall--......
  • Vue2路由
    路由前端路由:不同的网址对应各自的页面vue的前端路由:SPA应用要做出路由效果,就得判断当前网址,然后切换组件vue-router就是专门做切换组件的功能,它是一个单独的技术,......
  • Vue2组件
    组件创建组件的定义:实现应用中局部功能代码和资源的集合定义组件Vue.extend(option)option:和nnewVue(option)里的option几乎一致,但有点区别el不写原因:最终所有......
  • Vue3 项目在 H5 + ios 环境中,input 输入框在输入中文未选中汉字时会触发 chang 事件,导
    省流版:看解决3环境vue3+vant+H5需求input输入框为验证码(隐含需求:用户接收到验证码时,需要复制验证码后可以点击输入法的联想词直接输入验证码,且需要仅能输入英文......