A small program that calls chatGPT to create a small program, so programmers can use chatGPT

Not much nonsense, let’s get straight to the case. Let me show you the front-end code of the React framework generated by ChatGPT:

import React, { useState } from 'react';
import axios from 'axios';

const ChatApp = () => {
  const [inputText, setInputText] = useState('');
  const [outputText, setOutputText] = useState('');

  const handleInputChange = (e) => {
    setInputText(e.target.value);
  };

  const handleSubmit = async (e) => {
    e.preventDefault();
    try {
      const response = await axios.post('/api/goodsInfo', { id: 123456});
      setOutputText(response.data.output);
    } catch (error) {
      console.error(error);
    }
  };

  return (
    <div>
      <h1>ChatGPT小程序制作工具示例</h1>
      <form onSubmit={handleSubmit}>
        <input type="text" value={inputText} onChange={handleInputChange} />
        <button type="submit">发送</button>
      </form>
      <div>
        <p>{outputText}</p>
      </div>
    </div>
  );
};

export default ChatApp;

You can join the learning process by scanning the QR code of the mini program. The genuine and original chatGPT does not require scientific Internet access. It can be used with mobile phone + PC. Here is the magic tool to speed up your fishing.

 

Guess you like

Origin blog.csdn.net/lrbfly/article/details/130675230