React Bootstrap按钮

huangapple go评论61阅读模式
英文:

React Bootstrap Button

问题

Sure, here's the translation of the code part you provided:

<div className='phone-no'>
    <Link className='link-phone-no' to='tel:+12-345-678-89089'>
        +12-345-678-89089
    </Link>
</div>
英文:

Can anyone tell me how to add telephone number to the react bootstrap buttons, when clicking should call that number.
I have used div tags and link to make it look like a button. what I want to do is to make the button work the in the same way as anchor tag

code :

         &lt;div className=&#39;phone-no&#39;&gt;
            &lt;Link className=&#39;link-phone-no&#39; to=&#39;tel:+12-345-678-89089&#39;&gt;
              +12-345-678-89089
            &lt;/Link&gt;
          &lt;/div&gt;

答案1

得分: 1

以下是翻译好的部分:

"如我所见,import {Button} from 'bootstrap_path'; 然后将其与一个绑定了路径的onclick事件监听器一起使用,该事件将调用该函数。您可以使用useref钩子来获取所需的值。

<Button onclick={function_name} ref={myref}>一些文本{number}</Button>"
英文:

As I can see that import {Button} from &#39;bootstrap_path&#39;; And then use it having path binded with an onclick event listener that will call the function.
You may use useref hook to get the desired values with it.

&lt;Button onclick={function_name} ref={myref}&gt;some text{number}&lt;/Button&gt;

答案2

得分: 0

[![为按钮添加电话号码链接][1]][1]

  [1]: https://i.stack.imgur.com/4XeHN.png

这个方法可以使按钮作为链接组件,点击后可以跳转到输入的联系电话。第一组按钮代码适用于mui v5,第二组代码适用于react-bootstrap

首先导入这些组件:
import { Button } from 'react-bootstrap';
import { Button } from '@mui/material';
import { Link } from 'react-router-dom';

   导入 BrowserRouter 组件到 index.js 文件:
    ```````````````````````````
    <BrowserRouter>
      <App />
    </BrowserRouter>
    ```````````````````````````

    mui:
``````````````````````````````

    <Button
     component={Link}
     to="tel:+91-97875-97431"
     variant="contained"
     size="medium"
    >
    +91-97875-97431
    </Button>

````````````````````````````````````

    react-bootstrap:
```````````````````````````````````````

    <Button
        as={Link}
        to="tel:+91-97875-97431"
        variant="contained"
        color="success"
        size="large"
        >
        +91-97875-97431
        </Button>
```

<details>
<summary>英文:</summary>

[![Adding Link to Button with phone number][1]][1]


  [1]: https://i.stack.imgur.com/4XeHN.png


This method can make the button acts as a link component with clicking can go to a contact no we entered. The first set of button code is for mui v5 and second set of code is for react-bootstrap

import these components first:
``````````````````````````````````````````````````````````````
    import { Button } from &#39;react-bootstrap&#39;;
    import { Button } from &#39;@mui/material&#39;;
    import { Link } from &#39;react-router-dom&#39;;
```````````````````````````````````````````````````````````````
   import {BrowserRouter} from &quot;react-router-dom&quot;; --- index.js file
    before calling App component add BrowserRouter component
````````````````````````````
    &lt;BrowserRouter&gt;
      &lt;App /&gt;
    &lt;/BrowserRouter&gt;
`````````````````````````````
    mui:
``````````````````````````````

    &lt;Button
     component={Link}
     to=&quot;tel:+91-97875-97431&quot;
     variant=&quot;contained&quot;
     size=&quot;medium&quot;
    &gt;
    +91-97875-97431
    &lt;/Button&gt;

``````````````````````````````````````
    react-bootstrap:
```````````````````````````````````````
    

    &lt;Button
        as={Link}
        to=&quot;tel:+91-97875-97431&quot;
        variant=&quot;contained&quot;
        color=&quot;success&quot;
        size=&quot;large&quot;
        &gt;
        +91-97875-97431
        &lt;/Button&gt;

 


</details>



huangapple
  • 本文由 发表于 2023年5月18日 13:20:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76277934.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定