mirror of
				https://github.com/creativetimofficial/vue-material-kit.git
				synced 2025-10-31 21:26:11 +08:00 
			
		
		
		
	Показывает, но не работает
This commit is contained in:
		
							parent
							
								
									0c59ffddf4
								
							
						
					
					
						commit
						c094a72973
					
				| @ -1,10 +1,57 @@ | |||||||
|  | <script setup> | ||||||
|  | import { onMounted, onUnmounted } from "vue"; | ||||||
|  | import axios from 'axios'; | ||||||
|  | import { ref } from "vue"; | ||||||
|  | 
 | ||||||
|  | const searchQuery = ref(''); | ||||||
|  | const searchResultProjects = ref([]); | ||||||
|  | const searchResultUsers = ref([]); | ||||||
|  | 
 | ||||||
|  | const search = async () => { | ||||||
|  |   try { | ||||||
|  |     const projectsResponse = await axios.get(`http://somebodyhire.me/api/projects/?search=${searchQuery.value}`); | ||||||
|  |     searchResultProjects.value = projectsResponse.data; | ||||||
|  | 
 | ||||||
|  |     const usersResponse = await axios.get(`http://somebodyhire.me/api/profiles/?search=${searchQuery.value}`); | ||||||
|  |     searchResultUsers.value = usersResponse.data; | ||||||
|  |   } catch (error) { | ||||||
|  |     console.error('There was an error fetching the search results', error); | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| <template> | <template> | ||||||
|     <h1>Тут будет поиск!</h1> |     <div class="searchBar"> | ||||||
|  |         <input type="text" v-model="searchQuery" placeholder="Поиск по проектам и людям" /> | ||||||
|  |         <button type="submit" @click="search">Go</button> | ||||||
|  |     </div> | ||||||
|  |     <div class="results" v-if="searchResultProjects.length || searchResultUsers.length"> | ||||||
|  |         <div v-if="searchResultProjects.value.length"> | ||||||
|  |             <h2>Projects Results</h2> | ||||||
|  |             <p>Number of results: {{ searchResultProjects.value.length }}</p> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  |         <div v-if="searchResultUsers.value.length"> | ||||||
|  |             <h2>User Profile Results</h2> | ||||||
|  |             <p>Number of results: {{ searchResultUsers.value.length }}</p> | ||||||
|  |         </div> | ||||||
|  |      | ||||||
|  |     </div> | ||||||
|  |          | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|   </template> |   </template> | ||||||
| 
 | 
 | ||||||
|   <script> | <style scoped> | ||||||
|   export default { | .searchBar{ | ||||||
|     name: 'PresentationSearch', |     display: flex; | ||||||
|   } |     justify-content: center; | ||||||
|   </script> | 
 | ||||||
|  | } | ||||||
|  | </style> | ||||||
|    |    | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 FEARmeR
						FEARmeR