Giter VIP home page Giter VIP logo

vue-book's Introduction

vue-book

《Vue.js实战》源码及答疑

正版购买地址

已知勘误

感谢大家的反馈,目前已知的勘误如下,已修改,再次印刷时将更正。

  • [P26] 4.2章节个别错误 #2
  • [P60] 应该是:给 <select>添加属性 #13
  • [P81] 父链标题下有错别字 #5
  • [P87] 错别字 #23
  • [P135] VNode 对象参数 context 说明错别字 #24
  • [P204] htmlwebpackPlugin 更改为 htmlWebpackPlugin #20
  • [P271] 代码修改为 return year + '' + month + '' + day; #17
  • [P326] 倒数第三行少了个字符 's' #1

vue-book's People

Contributors

icarusion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-book's Issues

54页,购物车答案。

源码跟效果可以查看下列链接:vue购物车
顺便DISS一下作者,给个地址就不管事了,根据作者给的地址,根本就找不到这题的源码,新手一看到这题目直接懵逼,不知道从哪来下手,我也是借鉴了下方哥们的代码写出来的,不过我觉得我的代码跟清晰易读,嘻嘻。
发这个是希望还有买了这本书的新手不至于看到这个题目干瞪眼,最后再说一句:“Aresn, 能不能抽空回复一下我们这些新手?毕竟你出的书源码都不给我们!”

Page 106 练习题答案

  1. 添加键盘事件

    修改index-number.js 中的input为:

    // @keyup.up="handleUp"  @keyup.down="handleDown" 
    <input type="text" :value="currentValue" @change="handleChange"  @keyup.up="handleUp"  @keyup.down="handleDown" >
  2. 添加 prop - step 事件

    1. index.html 中修改
    // 添加 :step="10"
    <input-number v-model="value" :max="100" :min="0" :step="10"></input-number>
    1. Index-number.js 中修改
    // props 中添加
    step: {
      type: Number,
        default: 10
    }
    
    // methods 修改
    handleDown: function () {
      if (this.currentValue <= this.min) return;
      this.currentValue -= this.step;
    },
    handleUp: function () {
      if (this.currentValue >= this.max) return;
      this.currentValue += this.step;
    },

作用域插槽的这个示例代码列表渲染不出来,是我写错了吗

	<div id="app" v-cloak>
		<my-list :books="books">
			<template slot="book" scope="props">
				<li>{{props.bookName}}</li>
			</template>
		</my-list>
	</div>

	<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
	<script>

		Vue.component('my-list',{
			props: {
				books: {
					type: Array,
					default: function () {
						return [];
					}
				}
			},
			template: '\
			<ul>\
				<slot name="book">\
					v-for="book in books"\
					:book-name="book.name"\
				</slot>\
			</ul>'
		});

		var app = new Vue({
			el: '#app',
			data: {
				books: [
					{name: '《Vue.js 实战》'},
					{name: '《Javascript 语言精粹'},
					{name: '《Javascript 高级程序设计》'}
				]
			}
		})
	</script>

基础篇tabs组件代码问题

我按照书中的代码敲下来,浏览器只显示了一条横线,控制台没有任何报错!请问有谁遇到过

PAGE 56 v-model错误

理论上v-model@input:value的语法糖,是数据双向绑定的实现,但是代码中没有体现:value这一步,建议修改。

Page54 页扩展示例

跟书上的有点出入,但是大体上都差不多吧。。有点不是特别好。

扩展1
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="icon" href="https://cn.vuejs.org/images/logo.png" type="image/x-icon">
    <style>
        .completed {
            text-decoration: line-through;
        }
        .btn:focus,
        .btn:active:focus,
        .btn.active:focus,
        .btn.focus,
        .btn:active.focus,
        .btn.active.focus {
            outline: none;
        }
    </style>
</head>
<body>
<div id="app">
    <cart-show :lists="lists"></cart-show>
</div>
<template id="TASK-TEMPLATE">
    <div class="container">
        <div class="row">
            <div class="col-md-12" role="main" v-if="lists.length">
                <h1 class="text-center">购物车示例</h1>
                <table class="table">
                    <tr>
                        <th class="text-center">
                            <input type="checkbox" @click="checkAll" :checked="isCheckAll(lists)"> 全选
                        </th>
                        <th class="text-center">序号</th>
                        <th class="text-center">商品名称</th>
                        <th class="text-center">商品单价</th>
                        <th class="text-center">商品数量</th>
                        <th class="text-center">操作</th>
                    </tr>
                    <tr v-for="(list, index) in lists">
                        <td class="text-center col-md-1 ">
                            <input type="checkbox" @click="changeStatus(index)" :checked="hasCheck(index)"/>
                        </td>
                        <td class="text-center col-md-1">
                            {{ index+1 }}
                        </td>
                        <td class="text-center col-md-2 ">{{ list.name }}</td>
                        <td class="text-center col-md-2 ">{{ list.price }}</td>
                        <td class="col-md-3 text-center">
                            <div style="margin: 0 auto; width:150px;">
                                <div style="width:40px;float:left;">
                                    <button class="btn btn-info" style="border-radius: 50%;border-color:#ffffff;"
                                            @click="cartReduce(list)"
                                            :disable="list.count === 1">-
                                    </button>
                                </div>
                                <div class="col-md-1" style="width:50px;float:left;margin-top: 5px;">{{ list.count }}</div>
                                <div class="col-md-2" style="width:50px;float:left;">
                                    <button class="btn btn-info" style="display: block;border-radius: 50%;border-color:#ffffff;"
                                            @click="cartAdd(list)">+
                                    </button>
                                </div>
                            </div>
                        </td>
                        <td class="text-center">
                            <button class="btn btn-danger" @click="removeThisLine(key, index)">移除</button>
                        </td>
                    </tr>
                </table>
                <br>
                <div>
                    <input type="checkbox" class="pull-left" @click="checkAll" :checked="isCheckAll(lists)"> 全选
                    <button class="btn btn-danger pull-right" @click="ShowInfo()" v-if="prices">去支付{{ prices }}</button>
                </div>
            </div>
            <div v-else>
                <h1 class="text-center">购物车为空</h1>
            </div>
        </div>
    </div>
</template>
</body>
<script src="https://cdn.bootcss.com/vue/2.4.4/vue.js"></script>
<script>
    Vue.component('cart-show', {
        template: '#TASK-TEMPLATE',
        props: ['lists'],
        computed: {
            prices: function () {
                var prices = 0;
                for (var i = 0; i < this.lists.length; i++) {
                    var cart = this.lists[i];
                    if (cart.status) {
                        prices += cart.price * cart.count;
                    }
                }
                return prices > 0 ? prices.toString().replace(/\B(?=(\d{3})+$)/g, ',') : 0;
            }
        },
        methods: {
            cartReduce: function (list) {
                if (list.count === 1) return;
                list.count--;
            },
            cartAdd: function (list) {
                list.count++;
            },
            removeThisLine: function (index) {
                this.lists.splice(index, 1);
            },
            changeStatus: function (index) {
                this.lists[index].status = !this.lists[index].status;
            },
            hasCheck: function (index) {
                return this.lists[index].status;
            },
            isCheckAll: function (data) {
                var status = true;
                for (var i = 0; i < data.length; i++) {
                    if (!data[i].status) {
                        status = false;
                        return status;
                    }
                }
                return status;
            },
            checkAll: function () {
                var status = this.isCheckAll(this.lists);
                status ? status = 0 : status = 1;
                for (var i = 0; i < this.lists.length; i++) {
                    this.lists[i].status = status;
                }
            },
            ShowInfo : function () {
                alert(this.prices)
            }
        }
    });

    var app = new Vue({
        el: '#app',
        data: {
            lists: [
                {name: 'Iphone7', price: 6188, count: 1, status: 1},
                {name: 'Ipad Pro', price: 5888, count: 1, status: 1},
                {name: 'Macbook Pro', price: 21488, count: 1, status: 1}
            ],
            carts: [
                {
                    company: "蔬菜公司",
                    data: [
                        {name: '榴莲', price: 244, count: 3, status: 1},
                        {name: '橘子', price: 20, count: 5, status: 1}
                    ]
                },
                {
                    company: "apple公司",
                    data: [
                        {name: 'Iphone7', price: 6188, count: 1, status: 1},
                        {name: 'Ipad Pro', price: 5888, count: 1, status: 1},
                        {name: 'Macbook Pro', price: 21488, count: 1, status: 1}
                    ]
                }
            ]
        }
    })
</script>
</html>
扩展2
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="icon" href="https://cn.vuejs.org/images/logo.png" type="image/x-icon">
    <style>
        .completed {
            text-decoration: line-through;
        }

        .btn:focus,
        .btn:active:focus,
        .btn.active:focus,
        .btn.focus,
        .btn:active.focus,
        .btn.active.focus {
            outline: none;
        }
    </style>
</head>
<body>
<div id="app">
    <cart-show :lists="carts"></cart-show>
</div>
<template id="TASK-TEMPLATE">
    <div class="container">
        <div class="row">
            <div class="col-md-12" role="main" v-if="lists.length">
                <h1 class="text-center">购物车示例</h1>
                <table class="table" v-for="(cart, key) in lists" v-if="cart.data.length">
                    <tr>
                        <td class="text-left" colspan="6">
                            <input type="checkbox" @click="changeStatus(key, null)"
                                   :checked="isCheckChildAll(cart.data)"/>
                            {{ cart.company }}
                        </td>
                    </tr>
                    <tr>
                        <th class="text-center"></th>
                        <th class="text-center">序号</th>
                        <th class="text-center">商品名称</th>
                        <th class="text-center">商品单价</th>
                        <th class="text-center">商品数量</th>
                        <th class="text-center">操作</th>
                    </tr>
                    <tr v-for="(list, index) in cart.data">
                        <td class="text-center col-md-1 ">
                            <input type="checkbox" @click="changeStatus(key, index)" :checked="hasCheck(key, index)"/>
                        </td>
                        <td class="text-center col-md-1 ">
                            {{ index+1 }}
                        </td>
                        <td class="text-center col-md-2 ">{{ list.name }}</td>
                        <td class="text-center col-md-2 ">{{ list.price }}</td>
                        <td class="col-md-3 text-center">
                            <div style="margin: 0 auto; width:150px;">
                                <div style="width:40px;float:left;">
                                    <button class="btn btn-info" style="border-radius: 50%;border-color:#ffffff;"
                                            @click="cartReduce(list)"
                                            :disable="list.count === 1">-
                                    </button>
                                </div>
                                <div class="col-md-1" style="width:50px;float:left;margin-top: 5px;">{{ list.count }}
                                </div>
                                <div class="col-md-2" style="width:50px;float:left;">
                                    <button class="btn btn-info"
                                            style="display: block;border-radius: 50%;border-color:#ffffff;"
                                            @click="cartAdd(list)">+
                                    </button>
                                </div>
                            </div>
                        </td>
                        <td class="text-center">
                            <button class="btn btn-danger" @click="removeThisLine(key, index)">移除</button>
                        </td>
                    </tr>
                    <tr></tr>
                </table>
                <br>
                <div>
                    <input type="checkbox" class="pull-left" @click="checkAll" :checked="isCheckAll(lists)"> 全选
                    <button class="btn btn-danger pull-right" @click="ShowInfo()" v-if="prices">去支付{{ prices }}</button>
                </div>
            </div>
            <div v-else>
                <h1 class="text-center">购物车为空</h1>
            </div>
        </div>
    </div>
</template>
</body>
<script src="https://cdn.bootcss.com/vue/2.4.4/vue.js"></script>
<script>
    Vue.component('cart-show', {
        template: '#TASK-TEMPLATE',
        props: ['lists'],
        computed: {
            prices: function () {
                var prices = 0;
                for (var i = 0; i < this.lists.length; i++) {
                    var cart = this.lists[i];
                    for (var j = 0; j < cart['data'].length; j++) {
                        var data = cart['data'][j];
                        if (data.status) {
                            prices += data.price * data.count;
                        }
                    }
                }
                return prices > 0 ? prices.toString().replace(/\B(?=(\d{3})+$)/g, ',') : 0;
            }
        },
        methods: {
            cartReduce: function (list) {
                if (list.count === 1) return;
                list.count--;
            },
            cartAdd: function (list) {
                list.count++;
            },
            removeThisLine: function (key, index) {
                this.lists[key]['data'].splice(index, 1);
                if (this.lists[key]['data'].length === 0) {
                    this.lists.splice(key, 1);
                }
            },
            changeStatus: function (key, index) {
                if (index * 1 || index === 0) {
                    this.lists[key]['data'][index].status = !this.lists[key]['data'][index].status;
                } else {
                    var data = this.lists[key]['data'];
                    var status = this.isCheckChildAll(data);
                    status = status ? 0 : 1;
                    for (var j = 0; j < data.length; j++) {
                        data[j].status = status;
                    }
                }
            },
            hasCheck: function (key, index) {
                return this.lists[key]['data'][index].status;
            },
            isCheckChildAll: function (data) {
                for (var j = 0; j < data.length; j++) {
                    if (!data[j].status) {
                        return false;
                    }
                }
                return true;
            },
            isCheckAll: function (data) {
                var status = true;
                for (var i = 0; i < this.lists.length; i++) {
                    var cart = this.lists[i];
                    for (var j = 0; j < cart['data'].length; j++) {
                        var data = cart['data'][j];
                        if (!data.status) {
                            return false;
                        }
                    }
                }
                return status;
            },
            checkAll: function () {
                var status = this.isCheckAll(this.lists);
                status ? status = 0 : status = 1;
                for (var i = 0; i < this.lists.length; i++) {
                    var cart = this.lists[i];
                    for (var j = 0; j < cart['data'].length; j++) {
                        var data = cart['data'][j];
                        data.status = status;
                    }
                }
            },
            ShowInfo : function () {
                alert(this.prices)
            }
        }
    });

    var app = new Vue({
        el: '#app',
        data: {
            carts: [
                {
                    company: "蔬菜公司",
                    data: [
                        {name: '榴莲', price: 244, count: 3, status: 1},
                        {name: '橘子', price: 20, count: 5, status: 1}
                    ]
                },
                {
                    company: "apple公司",
                    data: [
                        {name: 'Iphone7', price: 6188, count: 1, status: 1},
                        {name: 'Ipad Pro', price: 5888, count: 1, status: 1},
                        {name: 'Macbook Pro', price: 21488, count: 1, status: 1}
                    ]
                }
            ]
        }
    })
</script>
</html>
  • 水平有限😆

[daily实战项目]util.js文件prevDay函数返回日期不正确

[问题简述]
util.js文件的prevDay函数返回日期不正确,year, month , day为数字类型,相加结果为数字,非接口需要的时间格式;导致接口请求错误,其源码如下:

// 源码
// ...
// 获取上一天日期
Util.prevDay = function (timestamp = (new Date()).getTime()) {
    const date = new Date(timestamp);
    const year = date.getFullYear();
    const month = date.getMonth() + 1 < 10
        ? '0' + (date.getMonth() + 1)
        : date.getMonth() + 1;
    const day = date.getDate() < 10
        ? '0' + date.getDate()
        : date.getDate();
    return year + month + day;
};

修改如下:

// 修改
// ...
// 获取上一天日期
Util.prevDay = function (timestamp = (new Date()).getTime()) {
    const date = new Date(timestamp);
    const year = date.getFullYear();
    const month = date.getMonth() + 1 < 10
        ? '0' + (date.getMonth() + 1)
        : date.getMonth() + 1;
    const day = date.getDate() < 10
        ? '0' + date.getDate()
        : date.getDate();
    return year + '' + month + '' + day;
};

重复使用组件问题

P144
return createElement('div',[ChildNode,ChildNode]);

实际测试<p>text</p>渲染了两次

是vue版本更新的原因还是?

p81错别字 p124 代码多个参数

p81 父链 无线访问,可能想表达 无限访问。
p124 根据上下文,bind钩子中定义的documentHandler 中第二个if内 binding.value 应该是handleClose方法,此方法不需要参数,而书中代码传入了event,虽不影响执行效果,但令人费解。

书中内容详细,示例完整,是目前见过vue教程中的良品。如果中间再穿插源码解释就再好不过了。

In webpack 4.0,the webpack.optimize.UglifyJsPlugin has been removed

p203,plugins中的webpack.optimize.UglifyJsPlugin出现了错误
webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead.
经查之后webpack4.0版本中已经没有webpack.optimize.UglifyJsPlugin,此例子中,应该改成在去掉

new webpack.optimize.UglifyJsPlugin({
    compress:{
        warnings:false
    }
})

的基础上,在plugins并行的位置上添加

optimization: {
        minimizer: [
            new UglifyJsPlugin({
                uglifyOptions: {
                    compress: false
                }
            })
        ]
    },

代码运行

第一个Hello world的示例运行不了怎么回事。我这里把vue.js下载了下来

<title>Vue 示例</title> <script src="dist/vue.min.js"></script> <script> var app = new Vue({ el:'#app', data:{ name:'' } }) </script>

你好,{{ name }}

p114 Error compiling template

[Vue warn]: Error compiling template:

<div class="tabs">      <div class="tabs-bar">        <div          :class="tabCls(item)"          v-for="(item, index) in navList"          @click="handleChange(index)"          {{ item.label }}        </div>      </div>      <div class="tabs-content">        <slot></slot>      </div>    </div>
  • Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

报这个错。。模板明明是在

这一个根元素上的啊

template: '\
    <div class="tabs">\
      <div class="tabs-bar">\
        <div\
          :class="tabCls(item)"\
          v-for="(item, index) in navList"\
          @click="handleChange(index)"\
          {{ item.label }}\
        </div>\
      </div>\
      <div class="tabs-content">\
        <slot></slot>\
      </div>\
    </div>',

关于将项目发布服务器上启动代理服务的问题

假设是要将daily项目发布到服务器上直接访问链接即可那么一般情况我们只需要打包这个项目发布就可以了,但是daily中用到了node proxy.js启动代理服务,我们要在打包的时候怎么处理或者在发布的时候怎么处理才能把这个启动代理服务在访问项目链接的时候自动开启呢?
个人解决思路:
1.写一个脚本自动开启
2.用别的代理替代或使用axios跨域

p114 Error compiling template

[Vue warn]: Error compiling template:
<div class="tabs"> <div class="tabs-bar"> <div :class="tabCls(item)" v-for="(item, index) in navList" @click="handleChange(index)" {{ item.label }} </div> </div> <div class="tabs-content"> <slot></slot> </div> </div>

  • Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.

报这个错。。模板明明是在 <div class="tabs"> 这一个根元素上的啊

template: '\
    <div class="tabs">\
      <div class="tabs-bar">\
        <div\
          :class="tabCls(item)"\
          v-for="(item, index) in navList"\
          @click="handleChange(index)"\
          {{ item.label }}\
        </div>\
      </div>\
      <div class="tabs-content">\
        <slot></slot>\
      </div>\
    </div>',

page54扩展1

<html>
<head>
	<title></title>
	<style type="text/css">
		[v-cloak] {
		  display: none;
		}
		table {
		  border: 1px soli #e9e9e9;
		  border-collapse: collapse;
		  border-spacing: 0;
		  empty-cells: show;
		}

		th, td {
		  padding: 8px 16px;
		  border: 1px solid #e9e9e9;
		  text-align: left;
		}

		th {
		  background-color: #f7f7f7;
		  color: #5c6b77;
		  font-weight: 600;
		  white-space: nowrap;
		}
	</style>
</head>
<body>
	<div id="app" cloak>
	  <template v-if="list.length">
	    <table>
	      <thead>
	        <tr>
	          <th><input type="checkbox" @click="handleAll" :checked="isCheckedAll()">全选</th>
	          <th>序号</th>
	          <th>商品名称</th>
	          <th>商品单价</th>
	          <th>购买数量</th>
	          <th>操作</th>
	        </tr>
	      </thead>
	      <tbody>
	        <tr v-for="(item, index) in list">
	          <td><input type="checkbox" @click="handleChecked(index)" :checked="isChecked(index)"></td>
	          <td>{{ index + 1 }}</td>
	          <td>{{ item.name }}</td>
	          <td>{{ item.price }}</td>
	          <td>
	            <button @click="handleReduce(index)" :disabled="item.count===1">-</button>
	            {{ item.count }}
	            <button @click="handleAdd(index)">+</button>
	          </td>
	          <td>
	            <button @click="handleRemove(index)">移除</button>
	          </td>
	        </tr>
	      </tbody>
	    </table>
	    <div>总价:¥{{ totalPrice }}</div>
	  </template>
	  <div v-else>购物车为空</div>
	</div>
<script src="https://cdn.bootcss.com/vue/2.4.4/vue.js"></script>
<script type="text/javascript">
	var app = new Vue({
		  el: '#app',
		  data: {
		    list: [
		      {
		        id: '1',
		        name: 'iPhone 7',
		        price: 6188,
		        count: 1,
		        status : 1
		      },
		      {
		        id: '2',
		        name: 'iPad Pro',
		        price: 5188,
		        count: 1,
		        status : 1
		      },
		      {
		        id: '3',
		        name: 'MacBook Pro',
		        price: 21488,
		        count: 1,
		        status : 1
		      }
		    ]
		  },
		  computed: {
		    totalPrice: function() {
		      var total = 0;
		      for(var i = 0; i < this.list.length; i++) {
		      	var item = this.list[i];
		      	if(item.status) {
		      		 total += item.price * item.count;
		      	}
		      }
		      return total != 0 ? total.toString().replace(/\B(?=(\d{3})+$)/g,',') : 0;
		    }
		  },
		  methods: {
		    handleReduce: function(index) {
		      if(this.list[index].count === 1) return;
		      this.list[index].count--;
		    },
		    handleAdd: function(index) {
		      this.list[index].count++;
		    },
		    handleRemove: function(index) {
		      this.list.splice(index, 1);
		    },
		    handleChecked: function(index) {
		  		this.list[index].status = !this.list[index].status;
		  	},
		  	isChecked: function(index) {
		  		return this.list[index].status;
		  	},
	      	isCheckedAll: function() {
	  			//列表全为true该status才为true,否则为false
		  		var status = true;
		  		for(var i = 0; i < this.list.length; i++) {
		  			//一旦列表的status有一个为false则status就为false
		  			if(!this.list[i].status) {
		  				status = false;
		  				return status;
		  			}
		  		}
		  		return status;
	  		},
		    handleAll: function() {
		  		//拿到是否是全选
		  		var status = this.isCheckedAll();
		  		status = status ? 0 : 1;
		  		for(var i = 0; i < this.list.length; i++) {
		  			this.list[i].status = status;
		  		} 
		  	}
		  }
		})
</script>
</body>
</html>

112页标签页组件代码有错误

按照示例代码敲了一遍,发现设置的默认选中的标签没起作用,发现问题应该出在下面这里。
在index.html 中:

<tabs v-model="activeKey">
...

v-model 是用于表单类元素的数据双向绑定,而 tabs 组件内部并没有用到表单元素。
所以应该是改为 v-bind 绑定:

<tabs :value="activeKey">

以上为本人的个人理解,并手敲了一遍,改后运行没有问题。如有不合理之处,麻烦大大帮忙指出,谢谢。

P96异步更新队列疑问

书上说Vue会根据浏览器环境优先使用原生的Promise.then和MutationObserver,但是vue.js官方文档却是‘Vue 在内部尝试对异步队列使用原生的 Promise.then 和 MessageChannel‘,请问MutationObserver与MessageChannel有何区别,为什么两处的出入这么大?

P179面的数据通信问题

在《vue.js实战》这本书中,p179的v-textarea组件在数据绑定的时候,出现了
"vue.js:597 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value"
查过之后,是说Vue2中规定props的数据改成了单行流动,在组件内,不能修改由外层传来的数据。把_this.value=event.target.value
去掉就没有再报错了

标签页组件

hello,实战->标签页组件部分,请问tabs.js里面为什么要添加watch呢?直接在点击事件handleChange里面实现watch逻辑不就行了吗?

关于webpack章节,最好给出npm run dev & npm run build的区别

我认为这不是很好的入门方式:作者没有区分webpack和wepack-dev-server,会导致初级读者,按照书上将的内容,配置好webpack-dev-server的时候并不能输出打包的文件到dist目录。
个人建议:
应该将相关部分做一下修改,让入门读者不在迷糊,或者添加简单说明,而不是让人混淆,谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.