Code Monkey home page Code Monkey logo

Comments (3)

cobish avatar cobish commented on September 12, 2024

03 月 02 日

一直以为都为 node-sass 的安装而头疼,今天 google 到了不错的方法,妈妈再也不用担心我 npm 安装失败了。详情请戳这里

from demo.

cobish avatar cobish commented on September 12, 2024

03 月 23 日

Vue

  • 父组件调用子组件方法:

child.vue

<template>
  <div>child</div>
</template>

<script>
  export default {
    methods: {
      handleParentClick() {
        console.log('parent click');
      }
    }
  }:
</script>

parent.vue

<template>
  <div>
    <button @click="handleClick">点击</button>
    <child ref="child"></child>
  </div>
</template>

<script>
  import Child from './child';

  export default {
    component: {
      child: Child
    },
    methods: {
      handleClick() {
        this.$refs.child.handleParentClick();
      }
    }
  };
</script>

from demo.

cobish avatar cobish commented on September 12, 2024

03 月 30 日

Webpack

  • 尝试用 vue-cli 中的 webpack-simple 构建项目,发现 vue 单文件组件 sass-loader 的 sourceMap 没法定位到精确的位置(即具体的 sass 在 vue 文件中的行数,还有 @import 后 sass 文件里的代码行数)。

通过与 vue-cli 的 webpack 构建的 demo 比较,将以下代码改动以下即可使 sourceMap 准确定位 sass 代码。

修改前:

module.exports = {
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            'scss': 'vue-style-loader!css-loader!sass-loader'
          }
        }
      }
    ]
  },
  devtool: '#eval-source-map'
}

修改后:

module.exports = {
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            'scss': {
              loader: 'vue-style-loader?sourceMap!css-loader?sourceMap!sass-loader',
              options: {
                sourceMap: true
              }
            }
          }
        }
      }
    ]
  },
  devtool: '#eval-source-map'
}
  • 一直以来 vue 单文件组件在 chrome debug 我都需要先 console.log() 一句话,然后从 console 里找到相应的行数进去才能够 debug,突然发现了这一条特殊语句 debugger,再也不用老是写 console.log() 来 debug 了。
export default {
  name: 'app',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },

  mounted() {
    debugger  // 代码运行到此处会中断
    console.log(111);
  }
}

from demo.

Related Issues (13)

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.