2020-04-23

1.初始化,生成package.json的文件: npm init -y

2.安装一个vue: npm install vue -S

3.生成的node_modules里面创建的method.html

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
             <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
                         <meta http-equiv="X-UA-Compatible" content="ie=edge">
             <title>Document</title>
       <!--1.引入vue.js-->
       <script src="./node_modules/vue/dist/vue.js" ></script>
</head>
<body>
  <!--2.编写div页面元素-->
  <div id="app">
  <input type="text">+<input type="text">
  <button>=</button>
  <input type="text">
</div>
  <!--3.创建vue实例-->
  <script >
  const vm = new Vue({
  el:'#app',
  data:{},
  methods:{},
  })
</script>
</body>
</html>

加法计算

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
             <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
                         <meta http-equiv="X-UA-Compatible" content="ie=edge">
             <title>Document</title>
       <!--1.引入vue.js-->
       <script src="./node_modules/vue/dist/vue.js" ></script>
</head>
<body>
  <!--2.编写div页面元素-->
  <div id="app">
  <input type="text" v-model="first">+<input type="text" v-model="second">
  <button @click="add">=</button>
  <input type="text" v-model="result">
</div>
  <!--3.创建vue实例-->
  <script >
  const vm = new Vue({
  el:'#app',
  data:{
      first:0,
      second:0,
      result:0,
      },
  methods:{
      add(){
          // parseInt()返回一个整数
          this.result = parseInt(this.first)+parseInt(this.second)
      }
  },
  })
</script>
</body>
</html>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • -- encoding: utf-8 -- """@File : test.py@Time : 202...
    千沙qiansha阅读 224评论 0 0
  • 什么是 NPM npm之于Node,就像pip之于Python,gem之于Ruby,composer之于PHP。 ...
    ihoey阅读 6,289评论 2 36
  • 33、JS中的本地存储 把一些信息存储在当前浏览器指定域下的某一个地方(存储到物理硬盘中)1、不能跨浏览器传输:在...
    萌妹撒阅读 2,155评论 0 2
  • vue 生命周期 生命周期 vue实例从开始创建、初始化数据、编译模板、挂载Dom->渲染、更新->渲染、卸载等...
    想改名叫孟健康阅读 129评论 0 0
  • NPM笔记: 名字的含义: 1、是Node的开放式模块登记和管理系统 2、Node默认的模块管理器,是一个命令行下...
    名字神马的都是浮云阅读 927评论 0 3