mineadmin/MineAdmin-Vue

在跳转的时候怎么携带参数呢

Closed this issue · 3 comments

列如:
{
title: '角色', dataIndex: 'role_ids', width: 120, formType: 'select', multiple: true,
dict: { url: 'system/role/list?role_id=1', props: { label: 'name', value: 'id' } }, hide: true,
commonRules: [{ required: true, message: '角色必选' }],
editDefaultValue: async (record) => {
const response = await admin.read(record.id)
return response.data.roleList.map(item => item.id )
}
},
我想在这个url后面加上一个参数role_id的值

To append an additional parameter to the URL in your dict configuration, you can directly modify the URL string to include your new parameter. Here's a quick way to do it:

dict: {
  url: 'system/role/list?role_id=1&additionalParam=value', // Append your parameter here
  props: { label: 'name', value: 'id' }
},

Just replace additionalParam and value with the actual parameter name and value you want to add. This method allows you to dynamically adjust the URL based on your requirements, making it easy to pass extra data to your endpoint.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

url: 'system/role/list?role_id=1&additionalParam=value',这里的role_id后面跟的参数需要动态获取 @dosubot

To dynamically append a role_id parameter to your URL in Vue, you can use a computed property or a method that returns the URL with the dynamically included role_id. Here's how you can do it:

  1. Using a Computed Property: Ideal for reactive role_id values that change based on user interactions or other conditions.
import { computed } from 'vue';

const roleId = ref(''); // Your reactive role_id

const dynamicUrl = computed(() => {
  return `system/role/list?role_id=${roleId.value}&additionalParam=value`;
});
  1. Using a Method: Suitable for generating the URL on-demand, such as before making an API call.
import { ref } from 'vue';

const roleId = ref(''); // Set this based on conditions or user selection

function getDynamicUrl() {
  return `system/role/list?role_id=${roleId.value}&additionalParam=value`;
}

Replace additionalParam=value with any other parameters you need to include. Ensure roleId is updated based on your application's logic, and use the dynamic URL where needed in your component or API calls.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.