会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133786个问题
JAVA 全系列/第六阶段:项目管理与SSM框架/SpringMVC 35176楼

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Ajax案例</title>
    <script src="js/jquery-3.5.1.js"></script>
</head>
<body>
 <span>用户名:</span><input type="text" class="username">
 <span>密码:</span><input type="text" class="password">
 <button class="button">点击</button>
 <script>
     $('button').click(function () {
        $.ajax({
          //请求方式
           type:'post',
          //交互数据格式为JSON
          dataType:'json',
          //指明请求发送到PHP后台的地址
          url:'777.php',
          data:{
               myName:$('.username').val(),
               myPass:$('.password').val()
          },
          success:function (res) {
              if(res.infor==0){
                  alert('登录失败')
              }else {
                  alert('登录成功')
              }
          }
      });

  });
 </script>
</body>
</html>
<?php
  $username=$_post['myName'];
  $password=$_post['myPass'];
  $success=array('msg'=>'ok'),
  if($username=='beixi'&& $password=='123456'){
   $success['infor']=1;
  }else{
   $success['infor']=0;
  }
  echo json_encode($success);
?>

老师麻烦看一下前后端没法交互  谢谢老师

WEB前端全系列/第五阶段:前后端交互/PHP、数据库编程与设计 35178楼
JAVA 全系列/第六阶段:JavaWeb开发/Servlet技术详解 35179楼

package com.xhcxy;

import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

/**
 * 发送消息的线程Send1
 */
class Send1 extends Thread{
    private Socket socket;
    private Scanner scanner;
    public Send1(Socket socket,Scanner scanner){
        this.socket = socket;
        this.scanner = scanner;
    }
    @Override
    public void run() {
        this.send1Mgs();
    }
    public void send1Mgs(){
        Scanner scanner = null;
        PrintWriter pw = null;
        try {
            scanner = new Scanner(System.in);
            pw = new PrintWriter(this.socket.getOutputStream());
            while (true){
                String mgs = scanner.nextLine();
                pw.println(mgs);
                pw.flush();
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (scanner !=null){
                scanner.close();
            }
            if (pw != null){
                pw.close();
            }
            if (this.socket != null){
                try {
                    this.socket .close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
/**
 * 接收消息的线程Receive1
 */
class Receive1 extends Thread{
    private Socket socket;
    public Receive1(Socket socket){
        this.socket = socket;
    }
    @Override
    public void run() {
        super.run();
    }
    public void receive1Mgs(){
        BufferedReader br = null;
        try {
            br = new BufferedReader(new InputStreamReader(this.socket.getInputStream()));
            while (true){
                String mgs = br.readLine();
                System.out.println("他说:"+mgs);
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (br != null){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (this.socket != null){
                try {
                    this.socket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
public class GoodTcp {
    public static void main(String[] args) {
        Scanner scanner = null;
        ServerSocket serverSocket = null;
        Socket socket = null;
        try {
            scanner = new Scanner(System.in);
            System.out.println("请输入:server,<port>或者:<ip>,<port>");
            String str = scanner.nextLine();
            String[] arr = str.split(",");
            if ("server".equals(arr[0])){
                System.out.println("TCP Server Listen at"+arr[1]+"......");
                serverSocket = new ServerSocket(Integer.parseInt(arr[1]));
                serverSocket.accept();
                System.out.println("连接成功!!");
            }else {
                socket = new Socket(arr[0],Integer.parseInt(arr[1]));
                System.out.println("连接成功!!");
            }
            new Send1(socket,scanner).start();
            new Reaceice(socket).start();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (serverSocket != null){
                try {
                    serverSocket.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

为什么会链接成功报错,老师image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程(旧) 35180楼
Python 全系列/第八阶段:Vue框架/vue框架 35181楼
JAVA 全系列/第十二阶段:消息中间件(异步消息传递)/ActiveMQ 35182楼

老师为什么create store 不能使用 会报错

后来我根据建议安装了 Redux Toolkit

但是还是不会使用  Redux Toolkit

 

@deprecated
We recommend using the configureStore method of the @reduxjs/toolkit package, which replaces createStore.

Redux Toolkit is our recommended approach for writing Redux logic today, including store setup, reducers, data fetching, and more.

For more details, please read this Redux docs page: https://redux.js.org/introduction/why-rtk-is-redux-today

configureStore from Redux Toolkit is an improved version of createStore that simplifies setup and helps avoid common bugs.

You should not be using the redux core package by itself today, except for learning purposes. The createStore method from the core redux package will not be removed, but we encourage all users to migrate to using Redux Toolkit for all Redux code.

If you want to use createStore without this visual deprecation warning, use the legacy_createStore import instead:

import { legacy_createStore as createStore} from 'redux'

@不推荐使用

我们推荐使用 @reduxjs/toolkit 包的 configureStore 方法,它取代了 createStore。


Redux Toolkit 是我们推荐的当今编写 Redux 逻辑的方法,包括存储设置、reducers、数据获取等。


有关更多详细信息,请阅读此 Redux 文档页面:https://redux.js.org/introduction/why-rtk-is-redux-today


Redux Toolkit 中的 configureStore 是 createStore 的改进版本,它简化了设置并有助于避免常见错误。


你今天不应该单独使用 redux 核心包,除非是为了学习目的。核心 redux 包中的 createStore 方法不会被删除,但我们鼓励所有用户迁移到对所有 Redux 代码使用 Redux Toolkit。


如果您想在没有此视觉弃用警告的情况下使用 createStore,请改用 legacy_createStore 导入:


从“redux”导入 { legacy_createStore as createStore}


“createStore”已弃用。ts(6385)

index.d.ts(375, 4):该声明曾在此处标注为已弃用。


WEB前端全系列/第十六阶段:React企业级项目/企业级后台管理系统 35184楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/反射技术(旧) 35185楼
JAVA 全系列/第六阶段:项目管理与SSM框架/SpringMVC 35186楼

老师你好,我在进行边界值控制时好像没有生效,麻烦帮着看下问题在什么地方



var listLi = document.querySelector(".swiplerul").querySelectorAll("li")

var swiperBottomlist = document.querySelector(".swiper-bottom").querySelectorAll("li")

var right = document.getElementById("right")

var left = document.getElementById("left")

console.log(listLi.length);


// 控制图片的显示顺序

var num = 0


left.onclick = function(){

   

    num++

    console.log(num);

    imgDisplay()

   

   

}


right.onclick = function(){

   

    num--

    console.log(num);

    imgDisplay()

   

}



   

// 控制页面显示的方法

function imgDisplay(){

    // 边界值出来

    if(num > listLi.length-1){

        num = 0

    }

    if(num < 0){

        num = listLi.length-1

    }

    // 移除属性

    for(var i = 0;i<listLi.length;i++){

        listLi[i].removeAttribute("class")

        listLi[i].removeAttribute("style")

    }

    // 添加属性

    listLi[num].setAttribute("class","current")

    listLi[num].style.display="block"





    for(var i = 0;i<listLi.length;i++){

        swiperBottomlist[i].removeAttribute("class")

        swiperBottomlist[i].removeAttribute("style")

    }

    swiperBottomlist[num].setAttribute("class","current")

}

for(var i= 0;i<swiperBottomlist.length;i++){

    swiperBottomlist[i].idxx=i

    swiperBottomlist[i].onclick=function(){

        num=this.idexx

        imgDisplay()

    }

}

// 有问题

打印如下:

image.png

超过边界值的值也打印出来了,轮播图中只有4张图

WEB前端全系列/第二阶段:JavaScript编程模块/DOM模型 35187楼
JAVA 全系列/第十二阶段:消息中间件与高并发处理/RocketMQ(旧) 35188楼
Python 全系列/第二阶段:Python 深入与提高/模块 35189楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器 35190楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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