首页 > 解决方案 > 我将如何删除 reactJS 中当前选定的下拉行?

问题描述

我有一个选择行,在输入输入时添加数据。

<Input type="select" name="selectProf" id="selectProf">
        <option>-</option>
        {
           thanks.map((t,i) =>
           <option key={i}>{t}</option> )
        }
</Input>

But when the specific option is selected I would like it to delete the specific row rather than the whole data in select.

我之前的代码是这样的:

function handleDelete(){
        localStorage.setItem('profileID', '[]')
}

但这清除了数组,结果删除了选择中的所有内容。我试过这个:

    function handleDelete(){
        if (JSON.parse(localStorage.getItem('profileID')) === document.getElementById('selectProf').value){
            //code here
        }
    }

但是,这种方法不起作用,因为它是不正确的。我将如何删除特定的选择行?

标签: javascriptreactjsreactstrap

解决方案


推荐阅读