Vue.js

vue mint tabbar 组件 使用

空扰寡人 提交于 2021-02-01 11:36:27
原文链接: vue mint tabbar 组件 使用 网址 http://mint-ui.github.io/docs/#/zh-cn2/tabbar 底部选项卡,点击 tab 会切换显示的页面。依赖 tab-item 组件。 实现底部选项卡切换页面功能 是真滴方便。。。只需要设置图标和文字就行了,激活样式默认文字是蓝色,刚好和我的图标一样。。。 <template> <div class="container"> <router-view class="router-view"></router-view> <mt-tabbar v-model="selected"> <mt-tab-item v-for="i in tabs" :id="i.name" :key="i.name" @click.native="change(i)"> <img slot="icon" :src="selected==i.name ? i.active : i.base"> {{i.name}} </mt-tab-item> </mt-tabbar> </div> </template> <script> export default { name: "tab-mint", data() { return { selected: '订单', tabs: [ { active: "/static

通过vuecli创建vue

喜夏-厌秋 提交于 2021-02-01 10:31:08
一:安装node环境 1.下载地址:https://nodejs.org/zh-cn/download/ 2.检查是否安装成功:node -v 二:全局安装vue cli3 提示(可以安装淘宝镜像):npm install -g cnpm –registry=https://registry.npm.taobao.org 1.安装命令:npm install -g @vue/cli 2.卸载命令:npm uninstall vue-cli -g 3.查看是否安装成功:vue -V || vue --version 三:创建vue项目 1.vue create 项目名称 2. Default ([Vue 2] babel, eslint) vue2默认配置 Default (Vue 3 Preview) ([Vue 3] babel, eslint) vue3默认配置 Manually select features 手动配置 3. ( ) Choose Vue version->选择版本 (*) Babel->编译 ( ) TypeScript->是否支持TypeScript ( ) Progressive Web App (PWA) Support->是否支持pwa ( ) Router->vue路由 ( ) Vuex->vue状态管理 ( ) CSS Pre

Using image src from asset variables

假如想象 提交于 2021-02-01 04:48:23
问题 I have a problem with images recently. Everything is ok until you have to show a list of images on the page. The problem is that when we directly give an src for image with hardcoded string, it works with a url like ~/assets/any-image.png . But if I try to move url into any variable / object / array, I have to specify the :src="myVariable" which contains the URL. The code for example: <template> <div> Problem with images <img :src="image.url" alt=""> <img :src='require(image.url)' alt=""> <

Using image src from asset variables

浪子不回头ぞ 提交于 2021-02-01 04:46:50
问题 I have a problem with images recently. Everything is ok until you have to show a list of images on the page. The problem is that when we directly give an src for image with hardcoded string, it works with a url like ~/assets/any-image.png . But if I try to move url into any variable / object / array, I have to specify the :src="myVariable" which contains the URL. The code for example: <template> <div> Problem with images <img :src="image.url" alt=""> <img :src='require(image.url)' alt=""> <

Using image src from asset variables

帅比萌擦擦* 提交于 2021-02-01 04:46:40
问题 I have a problem with images recently. Everything is ok until you have to show a list of images on the page. The problem is that when we directly give an src for image with hardcoded string, it works with a url like ~/assets/any-image.png . But if I try to move url into any variable / object / array, I have to specify the :src="myVariable" which contains the URL. The code for example: <template> <div> Problem with images <img :src="image.url" alt=""> <img :src='require(image.url)' alt=""> <

Using image src from asset variables

霸气de小男生 提交于 2021-02-01 04:46:39
问题 I have a problem with images recently. Everything is ok until you have to show a list of images on the page. The problem is that when we directly give an src for image with hardcoded string, it works with a url like ~/assets/any-image.png . But if I try to move url into any variable / object / array, I have to specify the :src="myVariable" which contains the URL. The code for example: <template> <div> Problem with images <img :src="image.url" alt=""> <img :src='require(image.url)' alt=""> <

Vue v-bind与v-model的区别

有些话、适合烂在心里 提交于 2021-02-01 04:16:46
v-bind 缩写 : 动态地绑定一个或多个特性,或一个组件 prop 到表达式。 官网举例 <!-- 绑定一个属性 --> < img v-bind:src= "imageSrc"> <!-- 缩写 --> < img :src= "imageSrc"> <!-- 内联字符串拼接 --> < img :src= "'/path/to/images/' + fileName"> <!-- class 绑定 --> < div :class= "{ red: isRed }"> </ div> < div :class= "[classA, classB]"> </ div> < div :class= "[classA, { classB: isB, classC: isC }]"> <!-- style 绑定 --> < div :style= "{ fontSize: size + 'px' }"> </ div> < div :style= "[styleObjectA, styleObjectB]"> </ div> <!-- 绑定一个有属性的对象 --> < div v-bind= "{ id: someProp, 'other-attr': otherProp }"> </ div> <!-- 通过 prop 修饰符绑定 DOM 属性 --> < div v-bind

vue使用初探

旧城冷巷雨未停 提交于 2021-01-31 21:26:08
1.起步,准备 首先你需要到node.js的官网下载一个叫做node的软件下载完成后你就会得到node附赠的一个npm工具。当你安装完成后。打开命令行分别输入node -v回车和npm -v回车你就会看到版本号。切换国内镜像以提升下载速度。 npm install -g cnpm --registry =htttps://registry.npm.taobao.org 通过cnpm -v来验证是否安装成功。接下来就是安装webpack。命令如下 cnpm install -g webpack weboack-cli 安装Vue Cli 命令cnpm install -g @vue/cli 2.第一个vue应用 这里我们选择的时候webstorm。在file处选择新建项目之后选择新建vue的项目。可能构建的时间有些长不要着急稍微等一会马上就好。 当你的第一个vue应用被建出来后他大概是这个样子的。 这里你会看到就算有一个前端项目也是会占用端口的。 3.模板语法 vue的语法非常严格引用了就要声明使用。不然就会报错。 模板语法的结构基本上是这样的。当然这里有一点值得强调就是在template下只允许有一个根就是那个叫App的盒子。这里我们要说的是插值表达式。他的作用就是将data中的数据或者是其他的一些数据渲染进DOM中但是不同的是他是不会解析HTML中的标签的。在data中

axios详解

旧城冷巷雨未停 提交于 2021-01-31 09:51:02
vuejs 2 后 作者尤雨溪发布消息,不再继续维护vue-resource,官方推荐大axios。 Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中。 特性: 从浏览器中创建 XMLHttpRequests 从 node.js 创建 http 请求 支持 Promise API 拦截请求和响应 转换请求数据和响应数据 取消请求 自动转换 JSON 数据 客户端支持防御 XSRF 一、安装: 1、 利用npm安装npm install axios --save 2、 利用bower安装bower install axios --save 3、 直接利用cdn引入<script src=" https://cdn.bootcss.com/axios/0.18.0/axios.js "></script> 二、使用: 假如你安装了vue脚手架,则在main.js文件中添加如下代码: import axios from 'axios' Vue.prototype.$axios = axios 然后在组件中可以这样使用了: < script> export default { data() { return { visible: false }; }, methods: { getData() { this.$axios.get( "https

axios网络请求

荒凉一梦 提交于 2021-01-31 09:17:13
人的一生就像一篇文章,只有经过多次精心修改,才能不断完善。 你好,我是梦阳辰,期待与你相遇! 01.概述 Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中。 axios中文文档 Vue中发送网络请求有非常多的方式。那么,在开发中,如何选择呢?**选择一:**传统的Ajax是基于XMLHttpRequest(XHR) 为什么不用它呢? 非常好解释,配置和调用方式等非常混乱. 编码起来看起来就非常蛋疼. 所以真实开发中很少直接使用,而是使用jQuery-Ajax 选择二: 在前面的学习中,我们经常会使用jQuery-Ajax相对于传统的Ajax非常好用. 为什么不选择它呢? 首先,我们先明确一点:在Vue的整个开发中都是不需要 使用jQuery 了. 那么,就意味着为了方便我们进行一个网络请求,特意引用一个jQuery,你觉得合理吗? jQuery的代码1w+行. Vue的代码才1w+行. 完全没有必要为了用网络请求就引用这个重量级的框架. 选择三 :官方在Vue1.x的时候,推出了Vue-resource.>Vue-resource的体积相对于jQuery小很多.>另外Vue-resource是官方推出的. 为什么不选择它呢? 在Vue2.0退出后, Vue作者就在GitHub的Issues中说明了去掉vue-resource