会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132415个问题

老师,表单的输入与绑定中p标签里面的username一直没反应,显示不出来

<template>
  <div id="app">
    <div>
    <h3>模块语法</h3>
    <p>{{ msg }}</p>
    <div v-html="price"></div>  <!--原生html指令-->
    <div v-bind:class="active">hello,python</div>   <!--绑定对象属性进行操作-->
    <p>{{ conte *2}}</p>
    </div>

   <div>
     <h3>条件渲染</h3>
     <p v-if="flag">孙悟空</p>
     <p v-else>六耳猕猴</p>

    <template v-if="flag">
      <p>1</p>
      <p>2</p>
      <p>3</p>
    </template>

    <div v-show="flag">helle,show</div>
   </div>

   <div>
     <h3>渲染列表</h3>
     <button @click="addItemHanle">添加数据</button>
     <ul>
       <!--item代表一个变量,index代表的是索引,:key="index"是唯一标识id-->
       <li v-for="(item,index) in result" :key="index">{{item.text}}</li>
     </ul>
   </div>

   <div>
     <h3>事件处理</h3>
     <p v-if="flags">请多多关照</p>
     <button v-on:click="clickHandle">按钮</button>
     <ul>
       <!--item代表一个变量,index代表的是索引,:key="index"是唯一标识id-->
       <!--不传递参数的情况下对生成一个$event对象属性-->
       <li v-on:click.stop="getMessageHandle(item.text,$event)" v-for="(item,index) in result" :key="index">{{item.text}}</li>
     </ul>
      <!--prevent阻止事件进行调转-->
     <a v-on:click.prevent="clickIwenHanle" href="http://iwenwiki.com">iwen</a>
   </div>

   <div>
     <h3>表单的输入与绑定</h3>
     <p>{{username}}</p>
     <input type="text" v-model="username">
     <button @click="clickInputHale">获取</button>

   </div>
 



  </div>
</template>

<script>
import HelloWorld from './HelloWorld.vue'

export default {
  name: 'App',
  data(){
    return{
      msg:"这是一套模板语法",
      price:"<h1>百战程序员</h1>",
      active:"active",
      conte:0,
      flag:false,
      result:[
        {
          id:1001,
          text:"东京的水"
        },
        {
          id:1002,
          text:"印度的疫情"
        },
        {
          id:1003,
          text:"中国的高铁"
        },

      ],
      flags:false
    }
  },

  methods:{  //承载事件函数
    clickHandle(){
      this.flags=!this.flags  //进行取反的操作绑定事件,this绑定到属性flags=*
    },

    getMessageHandle(date,e){ //date代表是的参数的item.text文本信息,$event(固定写法)代表是e对象
      console.log(date,e);
    },

    clickIwenHanle(){
      console.log("吕小布")
    },

    addItemHanle(){
      // this.result.push({
      //   id:1003,
      //   text:"加油加油"
      // })
      this.result=this.result.concat([{id:1004,text:"加油"}]) //集成一个新的数组返回
    },

    clickInputHale(){
      console.log(this.username);
    }




  },

  components: {
  }
}
</script>

<style>
#app {
  font-family: Avenir,  antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>


Python 全系列/第八阶段:Vue框架/vue框架 4141楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/index.css">
</head>
<body>

<div class="container" style="width: 500px">
    <div class="row">
        <!--one-->
        <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="http://code.z01.com/img/2016instbg_01.jpg" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="http://code.z01.com/img/2016instbg_02.jpg" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="http://code.z01.com/img/2016instbg_03.jpg" class="d-block w-100" alt="...">
                </div>
            </div>
            <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>
    </div>
    <div class="row">
        <!--        two-->
        <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
            <div class="carousel-indicators">
                <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active"
                        aria-current="true" aria-label="Slide 1"></button>
                <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1"
                        aria-label="Slide 2"></button>
                <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"
                        aria-label="Slide 3"></button>
            </div>
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img src="./images/1.jpg" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="./images/3.jpg" class="d-block w-100" alt="...">
                </div>
                <div class="carousel-item">
                    <img src="./images/2.jpg" class="d-block w-100" alt="...">
                </div>
            </div>
            <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators"
                    data-bs-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="visually-hidden">Previous</span>
            </button>
            <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators"
                    data-bs-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="visually-hidden">Next</span>
            </button>
        </div>
    </div>
</div>
<script src="js/jquery-1.12.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>



image.png


老师,第二个例子是复制的bootstrap官网上的轮播图,但是效果并没有达到,第一个是文档中的,二者并没有差距,但实现效果为何不同呢?而且官网很多都实现不了,是什么原因?



WEB前端全系列/第四阶段:BootStrap框架模块/BootStrap4实战 4143楼
JAVA 全系列/预科阶段:职业规划/学习方法/就业和找工作需要注意事项 4144楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解 4150楼
JAVA 全系列/第六阶段:项目管理与SSM框架/Maven 4155楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637