红糖糍粑
似乎很奇怪,但这是您可以写的一种方法lookup-const data = { "^\/a": 'value1' , "^\/b": 'value2' , "^\/d": 'value3' }const lookup = (str = "", o = {}) => ( Object .entries (o) .find (([ k, _ ]) => (new RegExp (k)) .test (str)) || [] ) [1]console .log ( lookup ('/a', data) // value1 , lookup ('/b', data) // value2 , lookup ('/c', data) // undefined )