vuejs基础知识总结

1.数据库返回数据渲染dom。img图片src的问题

<img :src='"http://www.forsta.cn/webapp/res/upimg/thumb/"+list.img' alt="" width="100%" height="">

      属性添加。v-bind缩写 :

      不要花括号,需编译为字符。外加单引号

2.同理绑定自定义属性

<div class="pro-list" v-for="list in items" @click="goDetail" :data-value="list.hid"></div>

3.上面2绑定事件获取自身元素的属性值,

    e.target 拿到点击的目标元素

       event.currentTarget对象就是当前元素,vue传递event

获取属性:

 goDetail(event){
            console.log('go detail');
            console.log(event.currentTarget.getAttribute('data-value'))
        }

4.vue-router重定向:

{
  path:'/',
  redirect:'/index'
}
5.build 部署页面空白
config - index.js
assetsPublicPath: './',

var path = require('path')

module.exports = {
  build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',
    productionSourceMap: true,
    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  },
  dev: {
    env: require('./dev.env'),
    port: 8080,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false
  }
}
5.单数据绑定

   用户名<input type="text" name="username" v-model="uname">

                export default {
    name: 'hello',
    components:{
      bot
    },
    data () {
      return {
        uname:'',
        moveList:[1,2,3,4,5]
      }
    },
    mounted(){
      this.init()
    },





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值