簡體   English   中英

將現有應用程序轉換為 react 會產生意外的令牌“<”

[英]Converting an existing app to react produces unexpected token '<'

我是反應新手。 我有一個現有的傳統 web 應用程序(使用 jquery),我想將其轉換為 React,但在瀏覽器中出現錯誤。 我使用 create-react-app 創建了一個新的 React 項目。 在 index.html 中,我在下面添加了我的 html

<div id="root"></div>

my./src/index.js 是標准:

import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import './index.css'

ReactDOM.render(<App />, document.getElementById('root'))

我的 App.js 是標准的: import React, {Component} from 'react'

class App extends Component {
  render() {
    return (
      <div className="App">
        <h1>Hello, React!</h1>
      </div>
    )
  }
}

export default App

當我使用“npm start”運行它時,會顯示“Hello World”,然后是我現有的 html。 但是該頁面顯示了現有的 html,其背后沒有 javascript 功能。 index.html 包含指向現有 javascript 的鏈接,如下所示:

<script src="../src/components/SplitPane/SplitPane.js"></script>

javascript 以 jquery 開頭,如下所示:

(function($) {

  $.fn.splitPane = function() {
    var $splitPanes = this;
    $splitPanes.each(setMinHeightAndMinWidth);

在 Chrome 控制台中,我看到錯誤:

Uncaught SyntaxError: Unexpected token '<' (在 SplitPane.js 的第 1 行)

該行甚至沒有任何“<”或“>”標記,因此該錯誤沒有意義。

有任何想法嗎?

請檢查您的 HTML 代碼, >缺失。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM