簡體   English   中英

在 react.js 的錨標簽中添加參數

[英]Adding parameter in anchor tag in react.js

我正在嘗試在我的錨標記的href屬性中添加用戶名。 我的代碼是,

var Name = React.createClass({

    render: function() {
        return (
            <div>
                <a href="www.example.com/"+ { this.props.username} +"" className="post-title">{this.props.name}</a><br />
            </div>
        );
    }

});

但是,我收到一條錯誤消息,說undefined token +在該 href 屬性附近。 我認為這是因為我試圖在渲染方法中添加它。 那么,還有其他方法嗎?

謝謝..

刪除+ 它應該是:

<a href={"www.example.com/" + this.props.username} ...

另一種方法是:

<a href={`https://www.example.com/${this.props.username1}`}>link</a>

在中使用.map<div> 標簽-react.js</div><div id="text_translate"><p> 我真的很感激任何幫助。 所以該項目是一個反應項目。</p><p> 這是我獲取<a href="https://i.stack.imgur.com/WelCP.png" rel="nofollow noreferrer">的內容:獲取請求</a></p><p>這是我從服務器響應的內容: <a href="https://i.stack.imgur.com/e2QG3.png" rel="nofollow noreferrer">Response from server</a></p><p> 我試了一下 Postman,看看我收到的是什么類型的 json。 這是它返回的內容: <a href="https://i.stack.imgur.com/yg6IE.png" rel="nofollow noreferrer">Postman 測試</a></p><p>我遇到的問題是我無法 map 收到的數據。 一旦輸入鏈接,我只想在首頁上以一種很好的方式顯示接收到的數據。</p><p> 是否可以將 map 放在 div 標簽內? 或者還有另一種方法嗎?</p><p> <em><strong>請注意該項目是作為功能組件編寫的</strong></em></p></div>

[英]Using .map in <div> tag - react.js

暫無
暫無

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

相關問題 將組件添加到 React.js 添加 <textarea> 單擊React.js上的選項后,在&lt;select&gt;標記內添加一個標記 傳遞值<select>React.js 中的標簽 使用react.js呈現自定義html標記 如何使用 React.js 訪問標簽樣式 在中使用.map<div> 標簽-react.js</div><div id="text_translate"><p> 我真的很感激任何幫助。 所以該項目是一個反應項目。</p><p> 這是我獲取<a href="https://i.stack.imgur.com/WelCP.png" rel="nofollow noreferrer">的內容:獲取請求</a></p><p>這是我從服務器響應的內容: <a href="https://i.stack.imgur.com/e2QG3.png" rel="nofollow noreferrer">Response from server</a></p><p> 我試了一下 Postman,看看我收到的是什么類型的 json。 這是它返回的內容: <a href="https://i.stack.imgur.com/yg6IE.png" rel="nofollow noreferrer">Postman 測試</a></p><p>我遇到的問題是我無法 map 收到的數據。 一旦輸入鏈接,我只想在首頁上以一種很好的方式顯示接收到的數據。</p><p> 是否可以將 map 放在 div 標簽內? 或者還有另一種方法嗎?</p><p> <em><strong>請注意該項目是作為功能組件編寫的</strong></em></p></div> react.js 中的鏈接標簽重定向問題 在滾動 React.js 上更新 ID 標簽 為什么在運行時添加<script>標記不會加載javascript文件? (with react.js) React.js onChange<input> 標簽掛起
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM