会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132464个问题
2019人工智能(隐藏)/第十二阶段:项目-NLP自然语言处理/自然语言处理--聊天机器人 20687楼

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>分页</title>

    <script src="js/jquery-1.12.3.min.js"></script>

    <style>

        .fenye span{

            border: 1px solid #ccc;

            padding: 3px 5px;

            margin-right: 5px;

            cursor: pointer;

        }

        .fenye span.active{

            border: none;

            color: red;

            font-weight: bold;

        }

    </style>

</head>

<body>

    <ul id="list"></ul>

    <div class="fengye">      

    </div>

  <script>

   $.get('10get_data.php', function (res) {

        data=JSON.parse(res);

        //当前页

        var  nowindex=1;

     //每页显示的条数

        var  num=5;

        //总的条数 data.length

        //获取总的页数

        var zong=Math.ceil(data.length/5);

        $("<span>上一页</span>").appendTo('.fenye');

        for(var i=1;i<=zong;i++){

            $("<span>"+i+"</span>").appendTo('.fenye');

        }

        $("<span>下一页</span>").appendTo('.fenye');

        //默认第一页

        createpage(nowindex);

        function  createpage(nowindex){

            $('#list').empty();

            $('.fenye').find('span').eq(nowindex).addClass('active').siblings().removeClass('active');

            var end=num*nowindex;

            if(end>data.length){

                end=data.length;

            }

            //把第一页的数据展示出来,展示5条

            for(var j=num*(nowindex-1);j<end;j++){

                $("<li><a  href='#'>"+data[j]['title']+"</a></li>").appendTo('#list');

            }

        }


        //给页码绑定事件

        $('.fenye').find('span').click(function () {

           var page=$(this).html();

            if(page=='上一页'){

                nowindex--;

                if(nowindex<1){

                    nowindex=1;

                    return ;

                }

            }else if(page=='下一页'){

                nowindex++;

                if(nowindex>zong){

                  nowindex=zong;

                    return ;

                }

            }else{

                if(page==nowindex){

                    return ;

                }

                nowindex=page;

            }

            createpage(nowindex);

        })

    })


  </script>  

</body>

</html>


<?php

  $con=new PDO('mysql:host=localhost;dbname=beixi;port=3306;charset=utf8','root','');

   $res=$con->query('select *  from news');

   if($res){

    $data =$res->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode($data);

   }else{

     echo '没有数据';

   }

?>

老师什么情况,代码没问题



image.png

WEB前端全系列/第六阶段:Http服务与Ajax模块(旧)/Http服务与Ajax编程 20688楼

2.png

老师 我运行效果都没问题,就是控制台这里不一样,我查看不了看不太懂我这是怎么回事?

WEB前端全系列/第九阶段:HTML5新特性模块/HTML5新特性 20689楼
Python 全系列/第四阶段:函数式编程和核心特性/python新特性 20690楼

代码异常,请求支援

package baizhanzuoye;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class TestCopyFile {
	public static void main(String[] args) {
		copydir(new File("D:\\我是你"),new File("E:\\我是你"));
		
	}
	
	public static void copydir(File olddir,File newdir) {
		if(newdir.exists()) {
			newdir.mkdir();
		}
		File[] files=olddir.listFiles();
		for(File f:files) {
			if(f.isFile()) {
				copyfile(new File(olddir+"\\"+f.getName()),new File(newdir+"\\"+f.getName()));
			}else {
				copydir(new File(olddir+"\\"+f.getName()),new File(newdir+"\\"+f.getName()));

			}
		
	}
	}
	
	
	public static void copyfile(File rread,File wwirte) {
		BufferedInputStream bis=null;
		BufferedOutputStream bos=null;
		try {
			bis = new BufferedInputStream(new FileInputStream(rread));
			bos = new BufferedOutputStream(new FileOutputStream(wwirte));
			byte[] buf=new byte[1024];
			int len=0;
			if((len=bis.read(buf))!=-1) {
				bos.write(buf,0,len);
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			if(bos!=null)
		try {
			bos.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}if(bis!=null)
		try {
			bis.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	}
}

异常截图

image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 20692楼
Python 全系列/第一阶段:Python入门/编程基本概念 20693楼
Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask数据库 20695楼
JAVA 全系列/第七阶段:生产环境部署与协同开发/Docker 20697楼

<template>
  <div class="hello">
    <div>
      <span>{{shangpin.title}}</span><br><span>{{shangpin.content}}</span>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
// import qs from 'querystring'
import qs from 'querystring'
export default {
  name: 'HelloWorld',
  data(){
    return{
     shangpin:{
       title:'',
       content:''
     },
     flag:false
    }
  },
  props: {
    msg: String
  },
  mounted(){
    var that=this
    // axios.get('http://iwenwiki.com/api/blueberrypai/getChengpinDetails.php').then(function(res){
    //   // console.log(res);
    //   if(res.status==200){
    //     // console.log(res.data.chengpinDetails[0].content);
    //     that.shangpin.title=res.data.chengpinDetails[0].title
    //       that.shangpin.content=res.data.chengpinDetails[0].content;
       
       
    //   }
    // }).catch(function(err){
    //   console.log(err);
    // })

    // axios.get('http://iwenwiki.com:3000/search?keywords',{
    //   params:{
    //     keywords:'你瞒我瞒'
    //   }
    // }).then(res=>{
    //   console.log(res);
    // }).catch(err=>{
    //   console.log(err);
    // })

    // post请求
    //querystring.stringify 将对象变为字符串
    //querystring.parse() 将字符串变为对象
    // axios.post('http://iwenwiki.com/api/blueberrypai/login.php',qs.stringify({
    //   user_id:'iwen@qq.com',
    //   password:'iwen123',
    //   verification_code:'crfvw'
    // })).then(res=>{console.log(res);}).catch(err=>{console.log(err);})
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

老师为啥我导入那个querystring 模块 后台就起不来呢?

image.png

image.png


WEB前端全系列/第十九阶段:Vue2知识体系(旧)/网络请求 20700楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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